Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql new user access denied

Tags:

mysql

Just started with mysql. I login with root and follow the online reference to create a new user:

mysql> CREATE USER 'abc'@'%' IDENTIFIED BY '111111';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'abc'@'%' WITH GRANT OPTION;

then I quit and tried to login with the new user:

mysql --user=abc --password=111111 mysql

But got an error message:

Access denied for user 'abc'@'localhost' (using password: YES)

Did I missed something?

like image 972
Ryan Avatar asked Dec 31 '12 06:12

Ryan


People also ask

How do I fix MySQL Access Denied?

Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.

How do I give a new user permission in MySQL?

To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name.

How do I fix error 1045 28000 Access denied?

Set root user password Login as user root with blank password >mysql -u root mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'abc';


2 Answers

Run this to work

FLUSH PRIVILEGES

Once you have given the desired privileges for your user, you will need to FLUSH privileges in order to complete the setup and to make the new settings work. To do so, run this command within the SQL command prompt:

[EDIT]
If you want to connect from localhost also, you should create another account.

It is necessary to have both accounts for 'user' to be able to connect from anywhere as 'user'. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when 'user' connects from the local host. As a result, 'user'would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'user'@'%' account and thus comes earlier in the user table sort order. )

FYI: http://dev.mysql.com/doc/refman/5.5/en/adding-users.html

like image 168
Venu Avatar answered Oct 03 '22 23:10

Venu


In my case the problem was in password. After making it containing lesser amount of special characters, it started working.

like image 38
user109764 Avatar answered Oct 03 '22 23:10

user109764