MySQL allows remote login configuration

1、查看user表
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user,password from user;
+-----------------------+---------+-------------------------------------------+
| host                  | user    | password                                  |
+-----------------------+---------+-------------------------------------------+
| localhost             | root    | *D2DC387634BA98FE0528FC555B66B391FD009465 |
| localhost.localdomain | root    | *D2DC387634BA98FE0528FC555B66B391FD009465 |
| 127.0.0.1             | root    | *D2DC387634BA98FE0528FC555B66B391FD009465 |
| Localhost | | |
| localhost.localdomain | | |
+ ----------------------- + --------- + --- + ----------------------------------------
5 rows in the SET (0.00 sec)

2 provided remote connection
a first (change table method):
modify the value of the host field, the modifications to the localhost ip address requires a remote connection to a database or directly modify%.
Modified% said that all hosts can access the database through the root user.
mysql> update user set host = ' %' where user = 'root' and host = 'localhost';
run above a given statement may be:
ERROR 1062 (23000): Duplicate entry '% -root' Key for 'a PRIMARY'
do not control, proceed directly to:
MySQL> flush privileges;

or simply allow the user to create a new outreach:
INSERT INTO the mysql.user (Host, the user, password) values ( "%", "username", password ( "
. grant all privileges on `library name or *` * to 'username' @ '%' identified by 'password';  
flush privileges;

the second (Authorization Act):
As with root mysql to connect from any host server, then.
. GRANT ALL PRIVILEGES ON * * TO 'root' @ '%' IDENTIFIED BY ' password' the WITH the GRANT the OPTION;
mysql> the flush privileges;

If you want to allow a user to connect to the host myuser 192.168.0.77 mysql server and is available from ip 12345 as the password
. * * the GRANT ALL pRIVILEGES the ON the tO 'myuser'@'192.168.0.77' the IDENTIFIED BY '12345' the WITH the GRANT the OPTION;
MySQL> the flush privileges;

Note:
database Add user statement:
. * Grant All privileges to the testdb ON ' test_user '@' localhost 'identified by " password" with grant option;
WITH GRANT OPTION This option means that users can have their own authority delegated to others.
When creating the operation of the user does not specify WITH GRANT OPTION option will cause the user can not create a user using the GRANT command, or to other authorized users.
If you do not have the permission to grant this user, you can not add the phrase
 

Guess you like

Origin www.cnblogs.com/deverz/p/10985008.html