Cannot log in to phpMyAdmin with my root password

2019-02-08 18:57发布

问题:

So I am trying to log in to phpMyAdmin using my root password (Username: root Password: ******), however, I continue to receive the error: #2002 Cannot log in to the MySQL server

I am pretty sure I know the root password, as I have typed into terminal on Mac OS X the line:

sudo /usr/local/mysql/support-files/mysql.server start

and was prompted with a "Password:" line. I typed the password, and the terminal read:

Starting MySQL...SUCCESS! And thus the server started up. I am not sure why the same password is not working for phpMyAdmin.

I have tried setting the password in terminal with the command:

/usr/local/mysql/bin/mysqladmin -u root password *******

But I receive the output:

/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)' 

I would very much appreciate help. I am at my wits end with this. I have tried several websites, and the mySQL instructions are useless on this matter. A detailed explanation on how to solve this problem (on Mac OS X Lion) would be very helpful. Thank you.

Update:

I've been trying to reset the root password, and have been following these instructions: http://www.coolestguyplanet.net/how-to-change-the-mysql-root-password/

However, when I use the command: /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

I receive the following output:

111217 10:00:42 mysqld_safe Logging to '/usr/local/mysql/data/******-********-MacBook-Pro.local.err'.
111217 10:00:42 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld_safe: line 107: /usr/local/mysql/data/********-********-MacBook-Pro.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 144: /usr/local/mysql/data/*******-**********-MacBook-Pro.local.err: Permission denied
111217 10:00:42 mysqld_safe mysqld from pid file /usr/local/mysql/data/*********-********-MacBook-Pro.local.pid ended
/usr/local/mysql/bin/mysqld_safe: line 107: /usr/local/mysql/data/*******-*********-MacBook-Pro.local.err: Permission denied
**********-*********-MacBook-Pro:~ myname$ 

Why would my permission be denied??

回答1:

In config.inc.php change localhost to 127.0.0.1 for $cfg['Servers'][$i]['host'] key.



回答2:

Take a look at this tutorial

Make sure your password is correct, if you need it you can change it with this

/usr/local/mysql/bin/mysqladmin -u root -p password

When it asks for a password, do not enter anything, just hit enter. It will then ask you to enter new password, then confirm. Finished.

Then you will need also to do this.

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock


回答3:

  1. Change phpMyAdmin/config.sample.inc.php to phpMyAdmin/config.inc.php;
  2. In config.inc.php, change localhost to 127.0.0.1;
  3. There is another config.inc.php in phpMyAdmin/setup/frames/config.inc.php, please ignore it.


回答4:

When it says (using password: NO) it means that it isn't receiving a password.

Use /usr/local/mysql/bin/mysqladmin -u root -p *******



回答5:

In addition to Sepp's answer, I would also like to point out that if you have set MySQL port to another port (i.e. 3307) , you can append the port number like this:

$cfg['Servers'][$i]['host'] = '127.0.0.1:3307';

to the config.inc.php file

I hope anyone who used a different port number can benefit from my answer



回答6:

Hey I had this problem but I fixed this. I just created a new user for mysql and then you can just login to your phpmyadmin.

Do the following things:

mysql -u root -p

and then enter your password:

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'enter your password just right here';

and set the all permissions for your new user.

GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

and then

FLUSH PRIVILEGES;

Thank you.



回答7:

Best way to do this is:

Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.

Stop the MySQL Server.

sudo /etc/init.d/mysql stop

Start the mysqld configuration.

sudo mysqld --skip-grant-tables &

Login to MySQL as root.

mysql -u root mysql

Replace YOURNEWPASSWORD with your new password!

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;

hope this help someoneelse..it worked for me!!



回答8:

And check this mysql config file -

[mysqld] default_password_lifetime=0

https://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html