Reputation: 2552
Please forgive me for being a complete beginner:
I am trying to log into my very first mySQL database that I installed using easyPHP on my windows machine, using the cmd line. I am going to the \mysql\bin and entering the command:
mysql -u root
in order to log in, but I am getting the following message:
error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES)
Why is it using the password "YES"? Shouldn't there be no password at all? Do I need to restart mySQL or something? If so, how do I do that? If it's relevant, I did try to create the database using phpmyadmin, but had a few problems entering columns and decided I'd be better off working from the command line so I could learn all the commands as I went along.
Please keep in mind that this is my first time ever trying to work with a database, so be kind to me!
Upvotes: 9
Views: 48535
Reputation: 454
A modification for mysql- 5.7.10 on mac mac el capitan
sudo mysqld_safe --skip-grant-tables
Now open new window/tab on terminal and type
Upvotes: 0
Reputation: 19
agk-hp:~/$mysql
ERROR 1045 (28000): Access denied for user 'greg'@'localhost' (using password: NO)
agk-hp:~/$sudo cat /etc/mysql/debian.cnf|grep password
password = t7753my3D2x4yfQm
agk-hp:~/$mysql -u debian-sys-maint -p
Enter password: {t7753my3D2x4yfQm}
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> use mysql;
mysql> grant all privileges on *.* to 'root'@'localhost';
mysql> grant all privileges on *.* to 'greg'@'localhost';
agk-hp:~/$mysql
mysql>
Upvotes: 0
Reputation: 1598
When logging into MYSQL using the command line, you also have to specify the password if any. Your error message is telling you that the user "root" has a password attached to it. Not necessarily that the password is "YES" when you were installing easyPHP, it should have either provided you with a default password or allowed you to enter a password of your choosing.
According to the documentation of easyPHP:
[v1.6] My scripts worked perfectly with 1.5 but now I get this error : Warning: Forbidden access for user: 'user@localhost' (password: YES) when I want to connect to MySql.
Only the root user (without password) has the rights to connect to the database. Either modify your scripts to use it, or add the user you need (phpMyAdmin/users and privileges: See phpMyAdmin's documentation for more information).
mysql -u root -p
Now if you changed your root user password, you will need to specify that when prompted. Otherwise simply hit <Enter>
on your keyboard.
If you FORGOT the password to root, and have changed it, you will have to subsequently reinstall easyPHP.
Upvotes: 3
Reputation: 29932
To have mysql asking you for a password, you also need to specify the -p
-option:
mysql -u root -p
Upvotes: 8