On some distributions, MySQL is installed without asking you to set the default root password for the MySQL server. If you’re running Debian or Ubuntu, the MySQL install will prompt you to create your password. However, some distributions such as CentOS aren’t as friendly. When MySQL is first installed on CentOS, it finishes without any user interaction. In fact, it finishes without a set root password, without starting the MySQL service, and without configuring the MySQL service to start on system reboot/boot.
The Fix, Short Version:
1) Start the mysql service [user@linuxacademy]# service mysqld start2) /usr/
The Fix, Long Version:
Problem:On CentOS the MySQL install process does not start the MySQL daemon, it does not add it to a run time start up configuration and it does not ask you to set a root user password during the install.Solution:1. Install the MySQL Server
[email@example.com]$ sudo yum install mysql-server
2. Start the MySQL Server
[firstname.lastname@example.org]$ service mysqld start
You will notice here that when it starts the service for the first time, MySQL dumps some “todo” information on the screen which includes setting the Root password for MySQL.Setting The Root Password After MySQL Install on Yum Based DistributionsMySQL asks us to set the root password during first MySQL bootup.Set MySQL Root Password: mysqladmin -u root password ‘newpassword’Where the first password is literally the word password and newpassword is the password you want to set for your MySQL server.
Example: [pinehead@linuxacademy]# mysqladmin -uroot password fu09wf((3
The above example would set the password “fu09wf((3” for the root user.Configure MySQL To Start On System Restart/BootAdd the MySQL service to our start up run levels. By default, if we were to restart the system at this stage, MySQL would not boot up with the system and we would have to manually start the service again.
[pinehead@linuxacademy]# chkconfig –level 235 mysqld on
This would cause the MySQL service to start up anytime the system enters runlevels 2,3 or 5. Since our system usually runs in runlevel 3 when first booted we know MySQL will start when the server restarts from now on.