MySQL allows LAN or external IP remote access

From: http://jiony.iteye.com/blog/1672912

By default, Mysql only allows local access to the settings. If you want to access mysql through the command line on the external network, there is no way. If you need an external IP to connect to mysql, you need to ask mysql Add the relevant authorization to the "user" table in the database.

For example: let the newuser user use the newpwd password to link to the mysql server from the host IP: 192.168.1.3

Specific steps:

mysql>GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'192.168.1.3' IDENTIFIED

BY 'newpwd' WITH GRANT OPTION;

mysql>flush privileges;

grant syntax:

grant permission name (all permissions are used) on library name (*all). Table name (*all) to 'user name to be authorized'@'%'(% means all IPs , you can only have one IP) identified by "password";

identity check is performed using the 3 range columns of the user table (Host, User and Password). The server will only accept connections if the Host and User columns of the user table record match the client's hostname and username and the correct password is provided.

How to specify the Host value in the user table:

* The Host value can be a host name or IP number, or 'localhost' indicates the local host.

* You can use wildcard characters "%" and "_" in the Host column value.

* Host value '%' matches any host name, empty Host value is equivalent to '%'. Their meaning is the same as the pattern matching operation of the LIKE operator. For example, a Host value of '%' matches all hostnames, while '%.mysql.com' matches all hosts of the mysql.com domain.


Example:

mysql> grant all on *.* to 'root@%' identified by '123456';

Query OK, 0 rows affected (0.02 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327033561&siteId=291194637