Error 1045 (28000) Access denied for user 'root' @ 'localhost' (using password: YES)

Please forgive me for being a beginner:

I am trying to enter my very first mySQL database that I installed with easyPHP on my Windows machine using the cmd line. I go to \ mysql \ bin and enter the command:

mysql -u root 

to log in, but I get the following message:

 error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES) 

Why does he use the password "YES"? Shouldn't have a password at all? Do I need to restart mySQL or something like that? If so, how do I do this? If this is relevant, I tried to create the database using phpmyadmin, but had some problems with entering the columns and decided that I had better work from the command line so that I could learn all the commands as I walked.

Please keep in mind that this is my first time ever trying to work with a database, so be so kind to me!

+8
command-line mysql root
source share
4 answers

For mysql to ask you to enter a password, you also need to specify -p -option:

 mysql -u root -p 
+7
source share

When entering MYSQL using the command line, you also need to provide a password, if one exists. The error message says that the root user has a password attached to it. The password is not required to be β€œYES” when installing easyPHP, it should either provide you with a default password or allow you to enter the password of your choice.

According to easyPHP documentation:

[v1.6] My scripts worked perfectly with 1.5, but now I get this error: Warning: denied access for the user: "user @localhost" (password: YES) when I want to connect to MySql.

Only the root user (without password) has the right to connect to the database. Either modify your scripts to use it, or add the user you need (phpMyAdmin / users and privileges: see the phpMyAdmin documentation for more information).

mysql -u root -p

Now, if you changed the root password, you will need to indicate this when prompted. Otherwise, just press <Enter> on the keyboard.

If you forget the root password and change it, you will have to reinstall easyPHP afterwards.

+3
source share
 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> 
0
source share

Modification for mysql-5.7.10 on mac mac el capitan

  • sudo / usr / local / mysql / support-files / mysql.server stop
  • sudo mysqld_safe --skip-grant-tables

    Now open a new window / tab on the terminal and type

  • "mysql -u root"
  • use mysql
  • update user set authentication_string = password ('yourpassword'), where user = 'root';
0
source share

All Articles