XAMPP: MySQL said: Cannot connect: invalid settings ?

Everybody should be careful when dealing with the 'users' & 'privileges', if you're using PhpMyadmin. I had pretty horrendous experience with this.

To be honest, I was removing users & mistakenly removed the root user. Then, I couldn't even load the PhpmyAdmin at http://localhost/phpmyadmin. When I tried, I had the following error.This means that, I don't have any access to mysql server.

MySQL said:

Cannot connect: invalid settings.
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.

After searching for solutions for a little bit of time. I'd found the following solution. I write this blog post , so that it'll be helpful for somebody with the same problem.

Step 01.

First, stop the MySQL service using XAMPP Control Panel.


Step 02

Then, Run Command Prompt & go to the 'mysql' installation directory. In my case, It's C:/xampp/mysql.

cd C:/xampp/mysql

Step 03

Then, locate 'resetroot.bat' file and to edit it with notepad, run the following command in the command prompt.


notepad resetroot.bat

Step 04

Find 'bin\mysqld.exe' in the .bat file & in the same line locate a text simliar to '--no-defaults'. Add the following text after leaving a space. Save the file.


–datadir=c:/xampp/mysql/data

Step 05

Now, run resetroot.bat using Command Prompt. Then, Start MySQL service using XAMPP Control Panel.

That's it. You can reach PhpmyAdmin. Thank You.

18 comments:

Jacko :) said...

This is very helpful! Thanks a lot! :)

guest said...

thankyou!!!!!!! :D

ekopde said...

Thanks, it's work

Harsha Wansooriya said...

You're Welcome

Unknown said...

Thanks a lot Harsha.It worked for me :)

Unknown said...

I'd just discover this useful blog. But still, the same problem persist even i did all what have been thought to me. Anyone, need help please

Unknown said...

I'd just discover this useful blog. But still, the same problem persist even i did all what have been thought to me. Anyone, need help please

Nagesh said...

thanks , it started working

Nagesh said...

thanks its working

Unknown said...

I'd just discover this useful blog. But still, the same problem persist even i did all what have been thought to me. Anyone, need help please

Unknown said...

I'd just discover this useful blog. But still, the same problem persist even i did all what have been thought to me. Anyone, need help please

Unknown said...

I'd just discover this useful blog. But still, the same problem persist even i did all what have been thought to me. Anyone, need help please

Annie said...

Thank you so much! It works. :)

Unknown said...

i dont have the resetroot.bat file

ISHITA PARAKH said...

Could you help me out with this in ubuntu?

Ideas Dot Smart said...

If you have changed your localhost over different PORT, Then you should SET PORT in config.inc.php file $cfg['Servers'][$i]['host'] = '127.0.0.1:3307'.

In my case I have Set PORT on 3307 in MySQL.ini. So that I fixed my config.inc.php file with following line: $cfg['Servers'][$i]['host'] = '127.0.0.1:3307'

Following fix is working for me.

Unknown said...

Thanks It Worked!!!!!

Unknown said...

Still problem there pl. help