MySQL said: #1045 - Access denied for user 'root'@'localho

Problems with the Windows version of XAMPP, questions, comments, and anything related.

MySQL said: #1045 - Access denied for user 'root'@'localho

Postby mandeee » 19. January 2012 12:56

Hi,

I am very new to this and I need help.
I deleted the root user of my database by mistake and now I cannot access anything. I keep getting this error:

MySQL said:
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.


Please what can I do to resolve this? :oops:

Thanks.
mandeee
 
Posts: 1
Joined: 19. January 2012 12:49
Operating System: Windows 7

Re: MySQL said: #1045 - Access denied for user 'root'@'loc

Postby Sharley » 19. January 2012 16:21

Hello.

Here are some instructions to restore your lost super user root.

1. Stop Apache and MySQL by using the Control Panel.

2. Open a plain text editor and add the following 3 lines (nothing else) to the very top of a new page:
Code: Select all
INSERT INTO mysql.user (Host, User, Password) VALUES('localhost', 'root', PASSWORD(''));

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;

FLUSH TABLES;
It must be exactly as written in the code section above, you may copy and paste if you prefer.

3. Save the file into the C:\xampp\mysql folder as undoroot.sql.
(Change the folder location to where you have your own XAMPP installed if different from the default.).

4. Go back to the Control Panel and click on the Shell button.

5. At the Shell # prompt type
Code: Select all
mysqld --init-file="C:\xampp\mysql\undoroot.sql"
Click on Enter which should then start the MySQL server using the undoroot.sql file and the instruction it contains.
(Change the folder location from the default to where you have your own XAMPP installed.).

6. Next go to the Control Panel again where you should see that MySQL has started - click on the Stop button so that MySQL is no longer running.

7. Now Start Apache and MySQL, again using the Control Panel and then click on the MySQL Admin button where, if all goes to plan you should have access to phpMyAdmin.

8. Exit/close the shell console window.

Also you should now have access to all your databases that you had previous to accidentally deleting the root user.

Good luck. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: MySQL said: #1045 - Access denied for user 'root'@'loc

Postby Sharley » 07. March 2012 09:31

The above solution only applies if you have deleted the MySQL/phpMyAdmin super user root and as a consequence this topic has been split to carry on with another poster's issues here:
viewtopic.php?f=16&t=50076.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 199 guests