MYSQL add remote users or allow remote access three methods

添加远程用户admin密码为password GRANT ALL PRIVILEGES ON *.* TO admin@localhost IDENTIFIED BY \'password\' WITH GRANT OPTION GRANT ALL PRIVILEGES ON *.* TO admin@\"%\" IDENTIFIED BY \'password\' WITH GRANT OPTION

MySQL tutorial to add remote users or allow remote access three methods

 

method one

Login as root user, then:

grant all privileges on *.* to created username@"%" identified by "password";

flush privileges; * refresh the content just now*

Format: grant permission on  database tutorial name. Table name to user@login host identified by "user password";

            @ is followed by the client ip address (or host name) accessing mysql % represents any client, if you fill in localhost as

Local access (then this user cannot access the mysql database remotely).

At the same time, you can also set whether to have remote access rights for existing users. as follows:

use mysql;

update db set host = '%' where user = 'username'; (if it is written as host=localhost then this user does not have remote access rights)

flush privileges;

grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option;

 

Method Two

1. Use the grant statement to add: first use the root user on the database machine

Log in to mysql (I use remote control of the linux server, which is equivalent to logging in to mysql locally on the server), and then enter:

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

Add a user admin and authorize access through the local machine (localhost), password "something".

 mysql>grant all privileges on *.* to admin@"%" identified by 'something' with grant option;

Add a user admin and authorize access from any other host (wildcard %). Just use this statement.

2. Use the insert statement:

mysql>insert into user values('%','admin',password('something'), 'y','y','y','y','y','y',

'and','and','and','and','and','and','and','and')

   User information can be viewed in the users table in the mysql database, which is not described here. Count the number of y's.

   Well, use the admin account to connect and try it, I have been successful after repeated attempts, huh, huh!

 

Method three

添加远程用户admin密码为password 
grant all privileges on *.* to admin@localhost identified by 'password' with grant option 
grant all privileges on *.* to admin@"%" identified by 'password' with grant option


Due to the requirements of project development, the database design has to use remote mode. But the remote setting of the database is not so simple. The database of this project is mysql5.0. At first, I thought that as long as the database server is installed, remote connections can be made, but the setting of mysql is for the safety of users. The default setting of the system is that remote users are not allowed to connect, only local users can connect. As long as we set the value of the host of the administrator user of the system, it can be accessed by remote users.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325244935&siteId=291194637