Wednesday, May 27, 2015

Easy to Deal with MySQL Error #1045

When a user formatted PC and re-installed local server (XAMPP) then sometimes user got 1045 error message. This occurs when root@localhost wasn’t granted the essential rights a user tries to access phpMyAdmin after successful installation of the local server. Here is the complete error message which occurs on screen:
#1045 Access Denied for user 'root'@'localhost' (using password: YES)

We have different servers to use MySQL database like: WAMP, MAMP, LAMP and XAMPP. WAMP is for Windows, LAMP for Linux, MAMP for Mac OS X and XAMPP for all operating systems. It also supports perl, mercury mail, filezilla and some scripts. In this blog, I will try to help users to get rid from this error for any local host server by the use of phpMyAdmin.


User can try following methods to resolve this error. Your problem might be fixed using the first method or you have to perform all three.

First Method

  1. Start the command prompt and go to the XAMPP directory: cd ../../Program Files/xampp
  2. Now go to xampp->mysql->bin
  3. Now run the following command: mysql.exe --user=root --password= 
  4. After this, MySQL command line will start and we can change the –user= and –password= accordingly.
Second Method: In this method we create the batch file to make it easier. To do this just follows simple steps:

  1. Create a file mysql_command.bat in the XAMPP folder and edit this file with any text editor and paste in this:
      @echo off
      echoMySQL command line...
      mysql\bin\mysql.exe --user=root --password=
      pause
  2. Save the file and change the username and password if you changed username and password. Now run command.bat and command prompt will display with MySQL command line in running condition.
Third Method:Open the config.inc.php file which is located in localhost ->xampp ->phpmyadmin->config.inc.php

  1. Open this file using any text editor.
  2. Now find the code $cfg['Servers'][$i]['password'] = ''; // MySQL password
  3. Now change the password which you have created in step 1.
  4. Click on the Save button.

2 comments:

  1. Very helpful post for me. I fix this error by first method.

    ReplyDelete
  2. It is good to hear that, this post helps you to fix the error.

    ReplyDelete