How to enable remote connection to MySQL databases in CentOS

Source: Internet
Author: User
When the server does not run php or install phpmyadmin, it is necessary to remotely manage mysql. Because it is set under CentOS, the title is added with CentOS. the following commands should also be OK in debian and other systems. Mysql-uroot-pmysql # 1st mysql commands are run, and 2nd mysql commands are run on the mysql console: g

When the server is not running php or installedPhpmyadminRemote ManagementMysqlIt seems necessary. Because it is set under CentOS, the title is added with CentOS. the following commands should also be OK in debian and other systems.

Mysql-u root-p mysql # 1st mysql is the execution command, and 2nd mysql is the system data name

Run the following command on the mysql console:

Grant all privileges on *. * to 'root' @ '%' identified by '000000' with grant option;
# The root account is the user name, and % represents any host. the logon password specified by '123456' (this password can be set different from the local root password without affecting each other)
Flush privileges; # reload system permissions
Exit;

Allow port 3306

Iptables-I INPUT-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT
# Check whether the rule takes effect
Iptables-L-n # OR: service iptables status
# The production environment is insecure at this time. after remote management, close the port and delete the previously added rules.
Iptables-d input-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT

PS. the above iptables add/delete rules are temporary. if the rules take effect after restart, save the changes:
Service iptables save # OR:/etc/init. d/iptables save
In addition,
Vi/etc/sysconfig/iptables # add the following rule.
-A input-p tcp-m state -- state NEW-m tcp -- dport 3306-jACCEPT

SQLyog can be used in win system for remote database management software. several remote software is used, which is quite good.

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.