小编Ste*_*ins的帖子

正在创建新的 MySQL 用户...密码和权限不存在

通过命令行客户端以“root”身份连接到 MySQL,我正在尝试使用以下命令创建一个 MySQL 用户:

mysql> create user 'myuser'@'%' identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on MY_DATABASE.* to 'myuser'@'%' identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

用户已创建,但其密码和权限并未“固定”。当我尝试使用密码登录时,出现错误:

~$ mysql -u myuser -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: YES)
Run Code Online (Sandbox Code Playgroud)

但是,我可以在没有密码的情况下按 [enter] 登录:

~$ mysql -u myuser -p
Enter password: 
Welcome to the MySQL monitor. …
Run Code Online (Sandbox Code Playgroud)

mysql

4
推荐指数
1
解决办法
7135
查看次数

标签 统计

mysql ×1