Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using CentOS 6, logged in to MySQL as root, entering the command:

create user 'user123' identified by 'pass123';

works fine. But when I try and give that user super user privileges with:

grant all on *.* to 'user123' identified by 'pass123';

I get the error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


select * from mysql.user;

shows that root has Y in all columns, so should have all privileges.

I'd be very grateful if anyone could help me find why root is unable to grant privileges as I can't see why it wouldn't be working.


share|improve this question

Privileges in MySQL are tied to both a 'username' and a 'host'. The host can be a domain name, an IP address or 'localhost'. Any of these can include the wildcard %. If you connect from the wrong place, even with the right username and password, you will still get a permission denied error.

Each of these different users can have different access to different databases, tables, rows and commands.

It's also worth noting that '' is not the same as 'localhost' as using the mysql client on the command line will use the socket rather than IP to connect. If you want to use IP to connect when using the mysql client on the MySQL server, you can specify -h <IP address>.

To see all of the different 'users':

SELECT user,host,password FROM mysql.user;
share|improve this answer
-P sets the port, not the IP. – codecowboy Nov 22 '15 at 9:23
Indeed it does. No idea where -P came from. Fixed. – Ladadadada Nov 22 '15 at 16:04
up vote 0 down vote accepted

Had to circumvent the grant tables in the end. See here:

on how to do that

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.