ERROR 1064 (42000): 你的 SQL 语法有误;尝试在 mariadb 中授予插入权限
ERROR 1064 (42000): You have an error in your SQL syntax; Trying to GRANT INSERT privilege in mariadb
我在 mysql 终端中创建了一个用户。
CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'identifier';
我尝试授予用户权限
GRANT INSERT ON *.* TO 'webuser'@'localhost';
得到错误:
Access denied for user 'eligooch'@'localhost' (using password: YES)
所以我尝试了
sudo GRANT INSERT ON *.* TO 'webuser'@'localhost';
得到了
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sudo GRANT INSERT ON *.* TO 'webuser'@'localhost'' at line 1
所以我试图向用户授予权限,但我卡住了。
试试这个:
$ sudo mariadb -u root mysql -e "DROP USER 'webuser'@'localhost';"
$ sudo mariadb -u root mysql -e "CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'Password123#%';"
$ sudo mariadb -u root mysql -e "GRANT INSERT ON *.* TO 'webuser'@'localhost';"
$ sudo mariadb -u root mysql -e "SELECT host, user, Select_priv, Insert_priv FROM mysql.user;"
+-----------+---------+-------------+-------------+
| host | user | Select_priv | Insert_priv |
+-----------+---------+-------------+-------------+
| localhost | root | Y | Y |
| localhost | halley | Y | Y |
| localhost | webuser | N | Y |
+-----------+---------+-------------+-------------+
确保用户使用的密码符合密码策略
我在 mysql 终端中创建了一个用户。
CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'identifier';
我尝试授予用户权限
GRANT INSERT ON *.* TO 'webuser'@'localhost';
得到错误:
Access denied for user 'eligooch'@'localhost' (using password: YES)
所以我尝试了
sudo GRANT INSERT ON *.* TO 'webuser'@'localhost';
得到了
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sudo GRANT INSERT ON *.* TO 'webuser'@'localhost'' at line 1
所以我试图向用户授予权限,但我卡住了。
试试这个:
$ sudo mariadb -u root mysql -e "DROP USER 'webuser'@'localhost';"
$ sudo mariadb -u root mysql -e "CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'Password123#%';"
$ sudo mariadb -u root mysql -e "GRANT INSERT ON *.* TO 'webuser'@'localhost';"
$ sudo mariadb -u root mysql -e "SELECT host, user, Select_priv, Insert_priv FROM mysql.user;"
+-----------+---------+-------------+-------------+
| host | user | Select_priv | Insert_priv |
+-----------+---------+-------------+-------------+
| localhost | root | Y | Y |
| localhost | halley | Y | Y |
| localhost | webuser | N | Y |
+-----------+---------+-------------+-------------+
确保用户使用的密码符合密码策略