我尝试在 bash 上使用 MySQL 客户端执行 MySQL 的“GRANT”命令,但出现语法错误。看起来没问题。
**1。在 MySQL 客户端上启动并执行 **
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.36 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT ALL PRIVILEGES ON databasename.* TO 'username'@'localhost' -> IDENTIFIED BY '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 'password'' at line 1
我得到了错误。我该怎么办? 你能帮我一下吗?
系统告诉您错误以
->
开头。如果您查看任何在线帮助,您会发现没有任何帮助告诉您该命令需要它。
因此,您应该尝试:
GRANT ALL PRIVILEGES ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';