Install mySQL on CentOS Linux
Installing mysql on CentOS, is easy, as 1,2,3. Though i wouldnt say this will be as easy as windows’s installation.
In this short tutorial i will explain how to do it, via console, as most servers dont have GUI installed. And preassumeably, you are login as root and have active internet connection.
- Get installation package: to get mysql installation package easy (CentOS has yum repository manager). Just type yum install mysql-server on your CentOS’s console.
Type y, and let Yum do its job, until below screen appear.
Make sure mysql is started by typing /etc/init.d/mysql start
run mysql_secure_installation to set credential and security for your mysql, and enter your current root password, you can leave it blank because we havent set it up yet. And follow instructions on the screen.
- Set root password? [Y/n]: fill with Y if you want to set root password for your mysql. Root password is the top level access for your mysql, so be wise in use it. And dont forget the password.
- Remove anonymous users? [Y/n]: By default, mysql has anonymous user account that can be used by anyone to log into mysql without having user account. Remove anonymous user in production, meanwhile in development is up to you.
- Disallow root login remotely? [Y/n]: If you want root can be accessed from remote computer, you have to set it with n. By allowing root login remotely, your root account can be accessed from any computer that connected with your mysql machine.
- Remove test database and access to it [Y/n]: By default, mysql has database named ‘test’ that used only for testing purpose. You can remove it safely because it has no effect to your mysql system.
- Reload privilege tables now? [Y/n]: Fill with Y if you want to reload your privilege that had been set up immediately.
run mysql_install_db to adjust your mysql system tables.
Setting CentOS firewall. After your mysql has been installed on your machine, now the last step you have to do is giving firewall privilege to your mysql port, so it can be accessed from remote machine. Of course you have to do it, because in many cases i believe you wont access your mysql directly from your machine. To do this, on your CentOS Console, type setup and you will have below screen.
Choose Firewall configuration and Run Tool to get into Firewall configuration window.
Choose Customize, and fill Other ports with 3306 (default mysql port). And press OK.
Voila, your mysql has been set up, and please let me know if you have any problem installing it.