通过CLI拒绝访问myusername

时间:2014-08-10 13:41:53

标签: mysql

我正在尝试通过命令行创建数据库。这就是我输入的内容:

$ mysql
mysql> CREATE DATABASE my_db;

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'my_db'

在查看ERROR 1044 (42000): Access denied for 'root' With All Privilegesmysql logging in as different user的建议后,我跑了

$ mysql -u myusername -p
ENTER PASSWORD: 
ERROR 1045 (28000): Access denied for user 'myusername'@'localhost' (using password: YES)

有什么问题?

1 个答案:

答案 0 :(得分:0)

  

也许更具体的问题应该是:如何在MySQL上切换用户?

获得granted the necessary rights to myusername(使用mysql root帐户)后,您可exit and then re-enter the mysql shell

mysql --user=user_name --password=your_password db_name