This article describes basic installation of MySQL database server on CentOS 6. You might need to install other packages to let applications use MySQL, i.e PHP.

Installing and Setting up MySQL database Server:

1To install MySQL, input the following yum command:

yum -y install mysql-server

2To enable MySQL daemon to start on boot:

chkconfig mysqld on
or
/usr/bin/chkconfig mysqld on

3Start the service:

service mysqld start
or
/etc/init.d/mysqld start

4You should secure MySQL with the following command:

mysql_secure_installation
or
/usr/bin/mysql_secure_installation

5 – Script will assist you with this process by presenting several questions. Recommended default action is to select YES for all questions.The command prompt will ask for your current MySQL root password. Leave it blank by pressing ENTER.

Answer the command prompt as specified below:

Set root password? [Y/n] Y
New password: YourOwnPassword
Re-enter new password: YourOwnPassword
Remove anonymous user? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Login to MySQL:

1After successfully installing MySQL, login as root user:

mysql -u root -p mysql

2Give the password we have assigned when we ran the secure script, when prompted.

3Create new User and Database:

mysql> CREATE DATABASE demodb;
mysql> GRANT ALL ON demodb.* TO 'demouser'@'localhost' IDENTIFIED BY 'password';
mysql> QUIT;

4Connect to MySQL new database and user:

mysql -u demouser -p demodb

Adding MySQL port in iptables of CentOS:

1To edit /etc/sysconfig/iptables file, enter:

vi /etc/sysconfig/iptables

2Now append the following code to open tcp port 3306 for MySQL:

-A INPUT -m state –state NEW,ESTABLISHED -m tcp -p tcp –dport 3306 -j ACCEPT

3Save and close the file and restart iptables by giving following command:

service iptables restart

Esta resposta foi útil? 0 Utilizadores acharam útil (0 Votos)