How to set up MySQL remote access

Source: Internet
Author: User

How to set MySQL remote access MySQL is not accessible by remote machine by default, remote access can be turned on by the following configuration

On the MySQL server side:

Execute mysql command into MySQL command mode,

SQL code
    1. mysql> use mysql;   
    2. mysql>  Grant all on *.* to [ Email protected] '% '  identified by  ' admin '  with grant  option   
    3. #这句话的意思  , the computer that allows any IP address ( %  that means above)   Access this mysql  with the admin account    and password (admin) Server   
    4. #必须加类似这样的帐户 before you can log in remotely.  root account can not be remotely logged in, only local login   
mysql> use mysql;mysql> grant all on * * to [e-mail protected] '% ' identified by ' admin ' with GRANT OPTION; #这句话的意思, allow Any IP address (above the percent of this meaning) of the computer with the admin account  and password (admin) to access the MySQL server# must be similar to such an account before you can log on remotely. The root account cannot be logged on remotely and can only be logged on locally


So how to access it remotely?
On another MySQL client (PC with MySQL package, Windows or Linux)

Execute command:
SQL code
    1. Mysql-h172.21.5.29-uadmin-padmin is ready.
    2. 172.21.5.29 is the IP address of MySQL server, admin admin is just the remote access account set up on 172.21.5.29
Mysql-h172.21.5.29-uadmin-padmin   //172.21.5.29 is the IP address of MySQL server, admin admin is just the remote access account set up on 172.21.5.29.


Reference
mysql> use MySQL;
Mysql> Grant All on * * to [e-mail protected] '% ' identified by ' admin ' with GRANT OPTION;
#这句话的意思, allow any IP address (above the% that means) to access this MySQL Server with the admin account and password (admin)
#必须加类似这样的帐户, you can log in remotely. The root account cannot be logged on remotely and can only be logged on locally

I found a problem, if the above command you executed, you are localhost in the local, execute:
SQL code
    1. Mysql-hlocalhost-uadmin-padmin


The result is a failure.

It turns out that the above% does not include localhost

So you have to add such an order.

Mysql>grant all on * * to [email protected] ' localhost '   identified by ' admin ' with GRANT OPTION;

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.