# Set MySQL password, can't login to PHPMYADMIN, HELP!



## rmb

Hi Everyone,

I am new to PHP, MySql and Apache (WAMP), busy learning all the code. I've come accross my first problem and can't seem to figure this out, and it is probably so simple and right under my nose...

I set a MySQL password and I can successfully login to MySQL, but when I try go to phpmyadmin I now get:

"Access Denied

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."

I obviously know what is happening here, but I don't know where to go to fix this (where is the configuration exactly). I tried looking up the MySQL error #1045, but it just tells me what the error is, not how/where to fix it. 

Can anybody help me here please? Thanks!


----------



## Forged

If you open up your phpmyadmin folder you should see a file called config.inc.php.
Open config.inc.php in notepad or any other text editor/html editor.

In that file you should have a line that looks like this


Code:


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

Simply insert your password you set between the " '' " and save the file.

For example:



Code:


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


----------



## rmb

Excellent! Thank You, I don't think I would have found that easily


----------



## Forged

Hehe, I've made the same mistake myself


----------



## kylejjjjj

hi i am also new to this and i know this is an old thread but i am having the same problem but the fix above did not work 
not sure what i should do 
any help would be greatly appreciated


----------



## Laxer

Do you have access to edit the SQL files or are you hosted somewhere?

If you have access to cPanel. (yourdomain.com/cpanel)

You can log-in and go to mySQL databases and delete the old user and create the new one.

You may also be able to edit the password using SSH if you can connect that way.


----------



## kylejjjjj

yes i have access to the machine


----------



## Laxer

Let's try this first...

Try logging in as
Username: root
Password:
(empty)

If no go try the user: root with whatever password you think it is...

If that still does not work we will have to manually edit the files.


----------



## kylejjjjj

Laxer thanks for helping me with this but it was a no go with the passwords


----------



## Laxer

Before I go explaining manual editing...

are you using an actual server like IIS/Apache or a build like WAMP/XAMPP etc


----------



## kylejjjjj

im using IIS


----------



## Laxer

This should get you up and running:


> Hi,
> 
> Please perform these steps to reset windows MySQL server admin password details:
> 
> 1) Log on to the Windows System where MySQL is running as Administrator. Stop MySQL server if it is running. Go to the Services manager:
> Start Menu -> Control Panel -> Administrative Tools -> Services
> 
> Find MySQL service in the list and stop it.
> 
> 2) Create a text file and place the following command within it on a single line:
> 
> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’NewPassword’);
> 
> Save the file with any name. For example the file will be C:\mysql-pass.txt.
> 
> 3) Open the DOS command prompt:
> Start Menu -> Run -> cmd
> 
> 4) If MySQL is installed in C:\mysql. At the DOS command prompt execute this command:
> 
> C:\> C:\mysql\bin\mysqld-nt –init-file=C:\mysql-pass.txt
> 
> If MySQL is installed in another location, adjust the following commands accordingly
> 
> 5) The contents of the file named by the –init-file option are executed at server startup, changing the root password. After the server has started successfully.
> 
> 6) Stop the MySQL server and restart it in normal mode again. If MySQL server is ran as a service, start it from the Windows Services window.
> 
> 7) Connect to MySQL server by using the new password.
> 
> Thanks,
> 
> Shane G.


You must have set a custom password when you installed SQL.


----------



## SunsetLover

Hello.
I have a similar problem and I can't fix it.
A few months ago I used EasyPHP having set a password for phpmysql in config.inc.php and everything was ok. But for some time any project that before worked now it just couldn't connect to the database (having the same password as before). I reinstalled Easyphp and now (except the first time, when it has no set password), after I set a password I can't even connect to the phpmyadmin anymore. I tried installing VertrigoServ but I had the same problem.
I read somewhere that it can be from the cache, so I deleted all from Control Panel -> Network and Internet -> Internet Options -> Delete -> [select all] -> OK, and also I have used Disk clean-up to delete any temporary internet files. It seems that even so, my old user (root) and password (has 6 characters, as it had before, so I guess it's the same as the one that was set sometime ago) still appears on the PhpMyAdmin Login page. Maybe this is the problem but I don't know how to fix it.
Please help be! Thank you in advance and have a nice day.


----------



## SunsetLover

Later add: 

I've installed again easyphp and when I enter phpMyAdmin, as I said the first time has no password set so I can, but after I set a password in config.inc.php (or even if I change nothing in config.inc.php but I use a link in phpMyAdmin that takes me to the same url) I get the following error:
*Error*

*MySQL said: * 
#1045 - Access denied for user 'root'@'localhost' (using password: YES) 


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.


----------

