当前位置:   article > 正文

MySQL8 设置权限报错:ERROR 1396 (HY000)、ERROR 1064 (42000)、ERROR 1410 (42000)_operation alter user failed for 'root'@'%

operation alter user failed for 'root'@'%

 问题:

ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'

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 'MyAdmin123!@#'' at line 1

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

  1. D:\mysql-8.0.34-winx64\bin>mysql -uroot -p
  2. Enter password: *************
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 9
  5. Server version: 8.0.34 MySQL Community Server - GPL
  6. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> use mysql;
  12. Database changed
  13. mysql> alter user 'root'@'%' identified by 'MyAdmin123!@#';
  14. ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'
  15. mysql> grant all on *.* to root@'%' identified by 'MyAdmin123!@#';
  16. 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 'MyAdmin123!@#'' at line 1

解决:

  1. mysql> use mysql;
  2. Database changed
  3. mysql> update user set host = '%' where user = 'root';
  4. Query OK, 1 row affected (0.00 sec)
  5. Rows matched: 1 Changed: 1 Warnings: 0
  6. mysql> flush privileges;
  7. Query OK, 0 rows affected (0.00 sec)
  8. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
  9. Query OK, 0 rows affected (0.01 sec)
  10. mysql>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/821532
推荐阅读
相关标签
  

闽ICP备14008679号