Resetting MySQL Root Password with XAMPP on Localhost

后端 未结 15 1561
北荒
北荒 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条回答
  • 2020-11-30 21:41

    If you indeed forgot the root password to the MySQL server, you need to start it with the option skip-grant-tables. Search for the appropriate Ini-File my.ini (C:\ProgramData\MySQL Server ... or something like this) and add skip-grant-tables to the section [mysqld] like so:

    [mysqld]
    skip-grant-tables
    
    0 讨论(0)
  • 2020-11-30 21:41

    For me much better way is to do it using terminal rather then PhpMyAdmin UI.

    The answer is copied from "https://gist.github.com/susanBuck/39d1a384779f3d596afb19fcad6b598c" which I have tried and it works always, try it out..

    • Open C:\xampp\mysql\bin\my.ini (MySQL config file)
    • Find the line [mysqld] and right below it add skip-grant-tables. Example:

      [mysqld] skip-grant-tables port= 3306 socket = "C:/xampp/mysql/mysql.sock" basedir = "C:/xampp/mysql" tmpdir = "C:/xampp/tmp" [...etc...]

    • This should allow you to access MySQL if you don't know your password.

    • Stop and start MySQL from XAMPP to make this change take effect.
    • Next, in command line, connect to MySQL:

    C:\xampp\mysql\bin\mysql.exe --user=root

    • Once in MySQL command line "select" the mysql database:

    USE mysql;

    • Then, the following command will list all your MySQL users:

    SELECT * FROM user \G;

    • You can scan through the rows to see what the root user's password is set to. There will be a few root users listed, with different hosts.
    • To set root user's to have a password of your choice, run this command:

    UPDATE user SET password = PASSWORD('secret_pass') WHERE user = 'root';

    • -OR- To set all root user's to have a blank password, run this command:

    UPDATE user SET password = '' WHERE user = 'root';

    When you're done, run exit; to exit the MySQL command line.

    Next, re-enable password checking by removing skip-grant-tables from C:\xampp\mysql\bin\my.ini.

    Save changes, restart MySQL from XAMPP.

    0 讨论(0)
  • 2020-11-30 21:43

    You can configure it with the "XAMPP Shell" (command prompt). Open the shell and execute this command:

    mysqladmin.exe -u root password secret

    0 讨论(0)
  • 2020-11-30 21:43

    On xampp -> Phpmyadmin -> config.inc 21st line you see:

    $cfg['Servers'][$i]['password'] = '';
    

    Add your password here and restart your xampp. The password will change.

    0 讨论(0)
  • 2020-11-30 21:43
    1. Start the Apache Server and MySQL instances from the XAMPP control panel.
    2. Now goto to your localhost.
    3. Click on user accounts -> Click on Edit privileges -> You will find an option change password just change password as you want click on go. Image are given below
    4. 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.
    5. Open terminal window (not mac default terminal please check attached image)
    6. Then Run apt-get update in the newly opened terminal.
    7. Then run apt-get install nano this will install nano
    8. CD to cd ../opt/lampp/phpmyadmin
    9. Open and Edit nano config.inc.php and save.
    0 讨论(0)
  • 2020-11-30 21:45

    Steps:

    1. Open your phpMyadmin dashboard
    2. go to user accounts
    3. on the user section Get the root user and click [ Edit privileges ]
    4. in the top section you will find change password button [ click on it ]
    5. make a good pass and fill 2 pass field .
    6. now hit the Go button.

    7 . now open your xampp dir ( c:/xampp ) --> 8 . to phpMyadmin dir [C:\xampp\phpMyAdmin]

    1. open [ config.inc.php ] file with any text editor

    10 .find [ $cfg['Servers'][$i]['auth_type'] = 'config'; ]line and replace 'config' to ‘cookie’

    1. go to [ $cfg['Servers'][$i]['AllowNoPassword'] = true; ] this line change ‘true’ to ‘false’.

    last : save the file .

    here is a video link in case you want to see it in Action [ click Here ]

    0 讨论(0)
提交回复
热议问题