#2002 Cannot log in to the MySQL server

Shredder2500 picture Shredder2500 · Jul 18, 2013 · Viewed 33.2k times · Source

I am working on a windows server 2012 and trying to get PHPMyAdmin working. I cant get it to connect to the MySQL by root user or a non root user. I have searched and searched all over google. everywhere I saw it said to set allowroot and change localhost to 127.0.0.1 in the config.inc.php file. At first I could not find this file but then I read you have to change config.default.php to it and put it in the root folder. I did that. and here is what I changed

 $cfg['Servers'][$i]['host'] = "127.0.0.1"
//already had the next one set
$cfg['Servers'][$i]['AllowRoot'] = true

I still cant get it to login from any user on MySQL, and I keep getting the error

#2002 Cannot log in to the MySQL server.

config.inc.php: http://u16626886.onlinehome-server.com/config.inc.zip

Testing PHP and MySQL: http://u16626886.onlinehome-server.com:801/test.php

I figured out the problem just need to solve it now. If I put MySQL on the C: drive it works fine but if I put it on the D: drive, which is where I want it, PHP can not connect to it. Does anyone know why that is?

Answer

Johnbosco Adam picture Johnbosco Adam · Sep 24, 2015
It may be Mysql service is not running, try to start Mysql service

Sometimes Mysql Service May Not Run..
 Try the following
   1. Remove/Unstall the service
            a) Start Cmd As Administrator
            b) Type Mysql --remove
   2. Restart Pc
   3. Install
        a) Start Cmd As Administrator
        b) Use Cd ../ To locate the path for Mysqld (For me it is in C:\xampp\mysql\bin)
        c)Type mysqld --Install
   4. Restart Pc