简体   繁体   中英

Access denied for user 'username'@'localhost' (using password: YES)

I just recently installed mySQL on my Mac running 10.10.3, but I can't create any tables or modify anything associated with my databases. When I start mysql I logs me in as '@localhost'

mysql> select user();
+-----------------------+
| user()                |
+-----------------------+
| username@localhost    |
+-----------------------+
1 row in set (0.00 sec)

mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| @localhost     |
+----------------+
1 row in set (0.00 sec)

mysql> CREATE DATABASE ign;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'ign'

I even try running this to log into my sql.

mysql -u username -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)

I am so lost and any help would be greatly appreciated.

If you just installed it and do not know the root password, or are unsure of the password, try resetting the root password (assuming you have admin rights on the machine). Then create a user and apply the applicable grant permissions .

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM