mysql8.1 版本 You are not allowed to create a user with GRANT

背景:

jupyter notebook 使用python 操作mysql 数据库

Error: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

那就打开mysql8 commandline client 

>GRANT ALL PRIVILEGES ON *.* TO 'your_database'@'%' IDENTIFIED BY 'your_password';
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 'your_password'' at line 1

经过查询得知

mysql8版本,需要先赋予用户权限

  1. #先创建一个用户

  2. create user '用户名'@'%' identified by '123456';

  3. #再进行授权

  4. grant all privileges on *.* to '用户名'@'%' with grant option;

grant 时异常信息如下:

ERROR 1410 (42000): You are not allowed to create a user with GRANT

 可以用Windows powershell 

先切换到mysql bin 路径下,在操作


PS F:\IT\software\mysql8\bin> .\mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
PS F:\IT\software\mysql8\bin> .\mysql -u root -p

password:*************

mysql> GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

猜你喜欢

转载自blog.csdn.net/u013985879/article/details/131951770