3

I issued a command of:

DROP USER 'root'@'localhost'; GRANT ALL PRIVILEGES ON . TO 'root'@'%';

...in PhpMyAdmin. Immediately after the execution, I was forced out PhpMyAdmin. I got:

error

#1130 - Host 'localhost' is not allowed to connect to this MySQL server,

how to resolve my problem?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Steven
  • 24,410
  • 42
  • 108
  • 130
  • Were you issuing the command as 'root'@'localhost'? Commands are executed in the order you enter them, so DROP USER would have been executed first, and if you dropped the user you're trying to issue commands as, that's why you were "forced out of phpMyAdmin," and your second command (GRANT) would never be executed. I hope you have access to another user with GRANT privileges. – Jordan Running Dec 10 '09 at 03:55
  • You are right. The first command was executed but the second command was not executed. I don't have access to another user. Maybe I have, but I can not remember. – Steven Dec 10 '09 at 03:59
  • @Steven: What version of MySQL are you using? `mysqladmin` from the command line was recognized for me, using 4.1.x. I found the mysqladmin.exe in Program Files\MySQL 4.1\Bin - maybe you'll have to navigate in the command prompt to the bin directory in order to be able to run it? Wasn't the case for me. – OMG Ponies Dec 10 '09 at 05:35
  • Mine is MySQL 5.1. And the directory is E:\Program Files\MySQL\MySQL Server 5.1\bin>mysqld, when I enter E:\Program Files\MySQL\MySQL Server 5.1\bin>mysqld, I got Windows cannot find 'D:\Program'.Make sure you typed the name correctly,and then try again.To search for file,click the start button,and then click search – Steven Dec 10 '09 at 05:56

4 Answers4

8

Use the IP instead:

DROP USER 'root'@'127.0.0.1'; GRANT ALL PRIVILEGES ON . TO 'root'@'%';

For more possibilities, see this link.

To create the root user, seeing as MySQL is local & all, execute the following from the command line (Start > Run > "cmd" without quotes):

mysqladmin -u root password 'mynewpassword'

Documentation, and Lost root access in MySQL.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
  • From PHPMyAdmin, logged in as a user other than root with the appropriate permissions. – OMG Ponies Dec 10 '09 at 03:45
  • 1
    Now that's a problem. Can you give some details on the setup - can you access the box MySQL is on, either by Remote Desktop or SSH/etc? – OMG Ponies Dec 10 '09 at 03:52
  • MySQL is on my local machine. – Steven Dec 10 '09 at 03:57
  • That's good news - windows, linux or other? There's MySQL command line, or MySQL Administrator if you haven't installed it already: http://dev.mysql.com/downloads/gui-tools/5.0.html – OMG Ponies Dec 10 '09 at 04:04
  • I am using Windows, and I have installed MySQL Administrator. – Steven Dec 10 '09 at 04:08
  • The problem is, I can not log in MySQL Administrator. – Steven Dec 10 '09 at 04:09
  • Yeah, I just saw the comment about possibly not having a user with similar permissions. – OMG Ponies Dec 10 '09 at 04:13
  • Windows cannot find 'mysqladmin'.Make sure you typed the name correctly,and then try again.To search for file,click the start button,and then click search. – Steven Dec 10 '09 at 05:26
  • When I try to create the root user I got this error: mysqladmin: connect to server at 'localhost' failed error: 'Host 'localhost' is not allowed to connect to this MySQL server' How can I solve this? I tried everything! :( – Mitulát báti Apr 18 '14 at 16:02
0

Find the file "config.inc.php" under your phpMyAdmin directory and edit the following lines:

$cfg['Servers'][$i]['auth_type'] = 'config'; // config, http, cookie

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user

$cfg['Servers'][$i]['password'] = 'TYPE_YOUR_PASSWORD_HERE'; // MySQL password

Note that the password used in the 'password' field must be the same for the MySQL root password. Also, you should check if root login is allowed in this line:

$cfg['Servers'][$i]['AllowRoot']     = TRUE;        // true = allow root login

This way you have your root password set.

-1

Use this in your my.ini under

[mysqldump]
    user=root
    password=anything
f_puras
  • 2,521
  • 4
  • 33
  • 38
Prathap
  • 11
-2

open your my.ini file, then add this

skip-grant-tables

line under

[mysqld]

so it should be like this

[mysqld]
skip-grant-tables

Then restart your mysql in xampp

General Grievance
  • 4,555
  • 31
  • 31
  • 45
MUHINDO
  • 788
  • 6
  • 10