如何在Ubuntu MySQL数据库上授予用户特权?

时间:2019-12-07 19:24:44

标签: mysql privileges

我通过

root登录
sudo mysql -u root 

并使用以下命令创建数据库xxx:

CREATE DATABASE xxx;

我想使用以下命令为xxx上的用户webuser授予特权:

GRANT ALL PRIVILEGES ON xxx.*  TO 'webuser'@'localhost';

我收到以下消息:

ERROR 1133 (42000): Can't find any matching row in the user table

我在做什么错了?

其他信息:

用户已经存在。这个:

  

mysql>选择用户,从mysql.user托管,其中User ='webuser';

输出为:

+---------+------+
| User    | Host |
+---------+------+
| webuser | %    |
+---------+------+
1 row in set (0.00 sec)

1 个答案:

答案 0 :(得分:1)

最好使用此链接create user and add privileges

或在运行此命令之前 GRANT ALL PRIVILEGES ON xxx.* TO 'webuser'@'localhost'  你应该做这个 CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'password' 使用此命令,您在webuser上的mysql用户中将localhost添加为password,且密码为'{password' 然后为您的用户添加权限