MySQL/phpMyAdmin Reset ROOT PASSWORD?

2020-06-30 00:16发布

问题:

I'm having MySQL on RHEL, and phpMyAdmin interface also. I have normal MySQL user access which i remember but i forget the root password.

  • How to SAFELY reset the MySQL root password? (I have root account on O/S)

回答1:

From Here: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

Stop mysqld and restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.

Connect to the mysqld server with this command:

shell> mysql

Issue the following statements in the mysql client. Replace the password with the password that you want to use.

mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
    ->                   WHERE User='root';
mysql> FLUSH PRIVILEGES;

The FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change



回答2:

WINDOWS USERS

For me in wondows 8 this worked; First go to where you installed mysql, I was using wamserver and installed it under D:\Programs\wamp\bin\mysql\mysql5.6.12\bin so cd to that directory, then;

-> mysql UPDATE mysql.user SET Password=PASSWORD('xvpaic7q') -> WHERE User='root'

-> FLUSH PRIVILEGES