Summary of open MySQL Remote connection permission method

Source: Internet
Author: User
Tags flush mysql in port number

The simplest sentence

The code is as follows Copy Code

>>grant all privileges on *.* to root@ "%" identified by "passwd";
>>flush privileges;


Where "%" means that any host can log on to the server remotely. If you want to qualify only one machine to access it, replace it with the appropriate IP, and reload the permission data on the second line.

Login to MySQL

The code is as follows Copy Code

# mysql-uroot-p

If you cannot log in you can use Find/-name MySQL to search the MySQL program path, such as the MySQL program path:/usr/local/mysql/bin/mysql, we can log in:
#/usr/local/mysql/bin/mysql-uroot-p
Execute the following command:

# Grant all privileges in *.* to ' root ' @ ' 192.168.0.1′identified by ' Root-password ';
# flush Privileges;
# exit

192.168.0.1 is the client IP that connects to the MySQL server, and if all is specified, it is expressed in%.


It's better to be safe, we can fix it like 8.8.8.8. Only this IP can connect remotely


MySQL Remote connection permissions
It is recommended to set fixed IP2.

The code is as follows Copy Code

Mysql> GRANT all privileges on *.* to root@ "8.8.8.8" identified by "root";
mysql> flush Privileges;
Modify Firewall
Iptables-i input-p TCP--dport 3306-j ACCEPT

Note that the database port is not very good if it's not open.

The remote login account that opens MySQL has two big strides:

Make sure the firewall on the server does not block port 3306.

MySQL default port is 3306, you need to determine that the firewall does not block 3306 ports, or remote can not connect through 3306 ports to MySQL.

If you specified a different port when installing MySQL, open the port number that you specified in MySQL in the firewall.

If you do not know how to set up a firewall on your server, please consult your server administrator.

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.