1

I am trying to create a database via the command line. This what I typed:

$ mysql
mysql> CREATE DATABASE my_db;

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

After looking at advice from ERROR 1044 (42000): Access denied for 'root' With All Privileges and mysql logging in as different user, I ran

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

What is wrong?

codeforester
  • 39,467
  • 16
  • 112
  • 140
user3918985
  • 4,278
  • 9
  • 42
  • 63
  • possible duplicate of [Cannot log in with created user in mysql](http://stackoverflow.com/questions/1412339/cannot-log-in-with-created-user-in-mysql) – VMai Aug 10 '14 at 13:45
  • refer to this link: http://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw – H_alt Aug 10 '14 at 13:46
  • I can't seem to do all of those suggested. I can't DROP any user or flush privileges because the root user doesn't have any privileges at all?! Then how am I supposed to switch user to myusername??? – user3918985 Aug 10 '14 at 14:37
  • maybe the more specific question should be: how do I switch user on MySQL? – user3918985 Aug 10 '14 at 14:42

1 Answers1

0

maybe the more specific question should be: how do I switch user on MySQL?

Once you have granted the necessary rights to myusername (using the mysql root account), you can exit and then re-enter the mysql shell

mysql --user=user_name --password=your_password db_name
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250