Installing MySQL on Fedora has never been easier than before. If you are a first timer who wants to know how to install MySQL on a Fedora server or desktop, follow this guide to successfully install both MySQL client and server only in three steps.
Before you proceed to the installation, the environment settings for the snapshot pictures of the installation are provided below:
OS: Fedora 13 64-bit
Prerequisites: yum is installed, commands invoked on root shell
Step 1: Install mysql client and mysql server via yum
root# yum install mysql mysql-server
Step 2: Configure MySQL daemon (mysqld) to be started whenever the server is rebooted. This way MySQL will automatically start after reboot without you having to manually initialize the service from command prompt.
root# chkconfig --level 2345 mysqld on
root# /sbin/chkconfig --level 2345 mysqld on
Step 3: Create the first databases by starting mysql service from the command prompt. Invoking this command will create test and mysql databases in your system. However, test database is not essential. You can drop this database later from MySQL console.
root# service mysqld start
root# /sbin/service mysqld start
CONGRATULATIONS!! We are done with the installation.
After completing the installation, you will have a running database server and a root account to manage the databases. You may consider changing the root password by invoking mysqladmin command (please refer to screenshot in Step 3) or logging into mysql console and update the password. Since you may update the password several times in the future, you will be shown the additional steps to updating the root password from MySQL console.
Additional Step 1: Login to mysql console from the command prompt
root# mysql -u root
Additional Step 2: Change active database into mysql
mysql> use mysql;
Additional Step 3: Update the password for root account
mysql > update user set password=password('your-new-password') where user='root';
Additional Step 4: Quit the MySQL console and activate the change by reloading MySQL databases from the command prompt
mysql > quit;
root# mysqladmin -u root reload
Note: Since root password is initially empty. We don’t need to supply -p (password) flag. Once you have set up the password, you should modify the above command by adding extra -p flag every time you want to reload MySQL after root password change. Don’t forget to supply your old root password instead of your new root password since at the time you invoke the command, password change has not taken place.
After the password change is effective, you should also add -p flag evertime you connect to MySQL server from the command prompt.