CentOS installation of MySQL supports remote connection.

Source: Internet
Author: User

MySQL is widely used in small and medium websites on the Internet. In this article, we can learn how to install MySQL in CentOS to support remote connection.
MySQL is a small relational database management system. How can we install and use MySQL in CentOS and allow MySQL to support remote connection. Next we will learn the method.

After MySQL is installed in CentOS, by default, you cannot connect to the database server through a non-local connection. The solution is as follows:

1. Run mysql-u root-p mysql on the console. The CentOS system prompts you to enter the password of the root user of the database. after entering the password, you will be taken to the mysql console, the first mysql of this command is the execution command, and the second mysql is the system data name, which is different.

2. ON the mysql console, run grant all privileges on *. * TO 'root' @ '%' identified by 'mypassword' with grant option;
Flush privileges;

3. Run The 'root' @ '%' command on the mysql console to understand that "root" is the user name and "%" is the host name or IP address. "%" here represents any host or IP address, you can also replace it with any other user name or specify a unique IP address. 'mypassword' is the password for authorized users to log on to the database; in addition, it should be noted that I here are to authorize all permissions, you can specify part of the permissions, GRANT specific operation details see: http://dev.mysql.com/doc/refman/5.1/en/grant.html

4. If you are not at ease, You can execute select host and user from user on the mysql console. Check the content in the user table.

In this way, the CentOS system is installed to support remote connection to MySQL.

//////////////////////////////////////// /////////////////

For CentOS systems, it is best to check iptables settings. The procedure is as follows:
Suspend the iptables service
# Service iptables stop
View the iptables configuration file
# Vi/etc/sysconfig/iptables # Add the following rule.

-A input-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT

Open Port 3306 directly, instead of specifying an ip address to access port 3306.
Restart the iptables service
# Service iptables start
Only records are required for use from time to time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.