How to Set MySQL remote access in ZZ

Source: Internet
Author: User
By default, MySQL cannot be accessed through a remote machine. The following configuration allows you to enable remote access.

On the MySQL server:

Run the MySQL command to enter the MySQL command mode,

SQL code

  1. Mysql> use MySQL;
  2. Mysql> grant all on *. * to admin @ '%' identified by 'admin' with grant option;
  3. # Allow any IP address (% above) to access the MySQL server using the admin account and password (Admin ).
  4. # You must add an account like this to log on remotely. The root account cannot be remotely logged on. You can only log on locally.
Mysql> use MySQL; mysql> grant all on *. * To admin @ '%' identified by 'admin' with grant option; # allow any IP address (% above) use the admin account and password (Admin) to access this MySQL Server # You must add an account similar to this to remotely log on. The root account cannot be remotely logged on. You can only log on locally.

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

Run the following command:

  1. Mysql-h172.21.5.29-uadmin-padmin.
  2. // 172.21.5.29 is the IP address of MySQL server, and Admin admin is the remote access account just set on 172.21.5.29.
Mysql-h172.21.5.29-uadmin-padmin. // 172.21.5.29 is the IP address of the MySQL server, and Admin admin is the remote access account set on 172.21.5.29.
Reference mysql> use MySQL;
Mysql> grant all on *. * to admin @ '%' identified by 'admin' with grant option;
# Allow any IP address (% above) to access the MySQL server using the admin account and password (Admin ).
# You must add an account like this to log on remotely. The root account cannot be remotely logged on. You can only log on locally.

I found a problem. If you have finished executing the above command, you will be running localhost locally. Execute:

  1. Mysql-hlocalhost-uadmin-padmin
mysql -hlocalhost -uadmin -padmin  

The result is failed.

The above % does not include localhost.

So you must add such a command.

Mysql> grant all on *. * to admin @ 'localhost' identified by 'admin' with grant option;

By default, MySQL cannot be accessed through a remote machine. The following configuration allows you to enable remote access.

On the MySQL server:

Run the MySQL command to enter the MySQL command mode,

SQL code

  1. Mysql> use MySQL;
  2. Mysql> grant all on *. * to admin @ '%' identified by 'admin' with grant option;
  3. # Allow any IP address (% above) to access the MySQL server using the admin account and password (Admin ).
  4. # You must add an account like this to log on remotely. The root account cannot be remotely logged on. You can only log on locally.
Mysql> use MySQL; mysql> grant all on *. * To admin @ '%' identified by 'admin' with grant option; # allow any IP address (% above) use the admin account and password (Admin) to access this MySQL Server # You must add an account similar to this to remotely log on. The root account cannot be remotely logged on. You can only log on locally.

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

Run the following command:

  1. Mysql-h172.21.5.29-uadmin-padmin.
  2. // 172.21.5.29 is the IP address of MySQL server, and Admin admin is the remote access account just set on 172.21.5.29.
Mysql-h172.21.5.29-uadmin-padmin. // 172.21.5.29 is the IP address of the MySQL server, and Admin admin is the remote access account set on 172.21.5.29.
Reference mysql> use MySQL;
Mysql> grant all on *. * to admin @ '%' identified by 'admin' with grant option;
# Allow any IP address (% above) to access the MySQL server using the admin account and password (Admin ).
# You must add an account like this to log on remotely. The root account cannot be remotely logged on. You can only log on locally.

I found a problem. If you have finished executing the above command, you will be running localhost locally. Execute:

  1. Mysql-hlocalhost-uadmin-padmin
mysql -hlocalhost -uadmin -padmin  

The result is failed.

The above % does not include localhost.

So you must add such a command.

Mysql> grant all on *. * to admin @ 'localhost' identified by 'admin' with grant option;

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.