当前位置: 首页 >数据库 > mysql远程连接 Host * is not allowed to connect to this MySQL server

mysql远程连接 Host * is not allowed to connect to this MySQL server

mysql -u root -p

mysql>use mysql;

mysql>update user set host =’%'where user =’root’;

mysql>flush privileges;

 

 

mysql> use mysql

Reading table information for completion of table and column names

You can tu off this feature to get a quicker startup with -A

 

Database changed

mysql> update user set password=password('root123') where user='root' and host='localhost'

    -> ;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Waings: 0

 

mysql> select 'host' from user where user='root'

    -> ;

+------+

| host |

+------+

| host |

| host |

| host |

| host |

+------+

4 rows in set (0.00 sec)

 

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@‘%’ IDENTIFIED BY ‘root123’ WITH GRANT OPTION;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%’ IDENTIFIED BY ‘root123’ WITH GRANT OPTION' at line 1

mysql> grant all privileges on *.* to 'root'@'%' identified by 'root123' with grant option;

Query OK, 0 rows affected (0.00 sec)

 

mysql> update user set host='%' where user='root'

    -> flush privileges;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'flush privileges' at line 2

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select host from user where user='root'

    -> ;

+-----------------------+

| host                  |

+-----------------------+

| %                     |

| 127.0.0.1             |

| ::1                   |

| localhost             |

| localhost.localdomain |

+-----------------------+

5 rows in set (0.00 sec)

 

mysql> update user set host='%' where user='root';

ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select host,user from user where user='root'

    -> ;

+-----------------------+------+

| host                  | user |

+-----------------------+------+

| %                     | root |

| 127.0.0.1             | root |

| ::1                   | root |

| localhost             | root |

| localhost.localdomain | root |

+-----------------------+------+

5 rows in set (0.00 sec)

 

mysql> 

 

作者:三驾马车
来源链接:https://www.cnblogs.com/myibm/p/9488646.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/117868.html

标签:SQL_syntax
分享给朋友:

“mysql远程连接 Host * is not allowed to connect to this MySQL server” 的相关文章