Installing MySQL via YUM
Once the updates have finished we will be ready to install the MySQL server. Type the following command to install the MySQL server:
# sudo yum -y install mysql-server
Once the installation has finished we are ready to start our server for the first time. Upon initially starting it will create several test databases and the mysql system databases. To start the server type the following:
# sudo /etc/init.d/mysqld start
Now that we have the MySQL server running we need to secure our installation. Type the following command below to start the secure setup script:
# sudo /usr/bin/mysql_secure_installation
Current Root Password
You will be asked for your current root password. Because this is a new installation it is set to none. Press enter.
Set Root Password
If the above step worked correctly you should be prompted with a question asking you if you would like to set your root password. Please press Y and press Enter.
You will be asked for your root password twice. If it works you will see Success!.
Removing Anonymous Users
You will be prompted to remove the MySQL anonymous users. For security reasons we want to do this. The text above the question explains this topic in more detail. Press Y and then Enter.
Disallow Root Login
You will be asked if you would like to disallow remote login for the root user and only allow connections from the server itself. To keep our server secure you want to say Y and press Enter.
Delete test Database
MySQL ships with a default database called test. This is not needed and can be deleted. Press Y and then Enter to delete the test database and it’s associated users.
Reload Privilege Tables
This step will reload the user settings (called privilege tables) so all user changes will take effect. Press Y and then Enter to continue.