CentOS/Fedora/REL - Installing MySQL Database with YUM
This tutorial walks you through installing the popular Open Source database application, MySQL, on CentOS/Fedora/REL Linux systems by using the YUM Package Manager. The YUM Package Manager is an automatic installer/de-installer for Red Hat based systems. It will download requested applications from a network of repository servers where the latest stable versions of popular applications are stored. If you wish to install a newer version of an application than is available on the YUM repositories, you can always compile it from the source code.
For this article, we are making these assumptions:
- You are running a newly-created server with no other software installed besides the Rackspace Cloud original server installation image.
- You are running as a normal user with sudo privileges.
Updating Your Server
In order to keep your server secure, update all of the software on your server with YUM using this command:
# sudo yum -y update
Installing MySQL via YUM
After the updates are finished, use the following command to install the MySQL server:
# sudo yum -y install mysql-server
After the installation is finished, you can start the database application for the first time. Upon initial startup, it creates several test databases and the MySQL system databases.
Use this command in order to start the server:
# sudo /etc/init.d/mysqld start
Now that you have the MySQL server running, you need to secure the installation.
- Use the following command to start the secure setup script:
# sudo /usr/bin/mysql_secure_installation
- You will be asked for your current root password. Because this is a new installation, it is set to none. Press Enter.
- If the above step worked correctly, you are prompted with a question asking you if you would like to set your root password. Press Y and then Enter.
- Next, you are asked for your root password twice. If it works you will see a Success! message.
- For security reasons, you should remove the MySQL anonymous users when you are prompted. The text above the question explains this topic in more detail. Press Y and then Enter.
- For security reasons, disallow remote login for the root user and only allow connections from the server itself when you are prompted. Press Y and then Enter.
- MySQL ships with a default database called test. Since we do not need this, you can delete it. Press Y and then Enter in order to delete the test database and it's associated users.
- This step reloads the user settings (called privilege tables) so that all user changes take effect. Press Y and then Enter to continue.
Your MySQL installation is now finished. Keep in mind that this only supports local connections and does not allow you to connect remotely. The article MySQL - Connect to your database remotely explains how to make a remote connection from another server to your database.
© 2014 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER