Resetting MySQL Root Password with XAMPP on Localhost

后端 未结 15 1588
北荒
北荒 2020-11-30 21:11

So for the past hour I\'ve been trying to figure out how to reset my \'root\' password for MySQL as I cannot log into PHPMyAdmin. I\'ve tried changing the password in the co

15条回答
  •  萌比男神i
    2020-11-30 21:54

    Reset XAMPP MySQL root password through SQL update phpmyadmin to work with it:

    -Start the Apache Server and MySQL instances from the XAMPP control panel. After the server started, open any web browser and go to http://localhost/phpmyadmin/. This will open the phpMyAdmin interface. Using this interface we can manager the MySQL server from the web browser.

    -In the phpMyAdmin window, select SQL tab from the right panel. This will open the SQL tab where we can run the SQL queries.

    -Now type the following query in the textarea and click Go

    • "UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';"

    • hit go

    • "FLUSH PRIVILEGES;"

    • hit go

    -Now you will see a message saying that the query has been executed successfully.

    -If you refresh the page, you will be getting a error message. This is because the phpMyAdmin configuration file is not aware of our newly set root passoword. To do this we have to modify the phpMyAdmin config file.

    -Open the file C:\xampp\phpMyAdmin\config.inc.php in your favorite text editor. Search for the string:

    $cfg\['Servers'\]\[$i\]['password'] = ''; and change it to like this, 
    $cfg\['Servers'\]\[$i\]['password'] = 'password'; Here the ‘password’ is what we set to the root user using the SQL query.
    $cfg['Servers'][$i]['AllowNoPassword'] = false; // set to false for password required
    $cfg['Servers'][$i]['auth_type'] = 'cookie'; // web cookie auth
    

    -Now all set to go. Save the config.inc.php file and restart the XAMPP server.

    Modified from Source: http://veerasundar.com/blog/2009/01/how-to-change-the-root-password-for-mysql-in-xampp/

提交回复
热议问题