MySQL access denied 1045 error

Chris picture Chris · Oct 31, 2011 · Viewed 28.8k times · Source

I'm getting a very strange error, I've created a user 'testuser' with the following credentials:

CREATE USER 'testuser'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%';
FLUSH PRIVILEGES;

I have also modified my /etc/mysql/my.cnf not to bind to any single address. (Which afaik should accept connections from anywhere?) And restarted mysql.

And I can connect locally no problem.

I am running inside a virtual box on ubunutu.

Trying to connect from my windows machine, gives me MySQL error number 1045 Access denied for user 'testuser'@'192.168.0.22'.

I'm confident that it's not a networking problem as changing the host or port gives a different error "Cannot connect to the specified instance"

Logging in as root and looking at the users table - all looks as expected. (Single row, '%' for host and all permissions set.)

I've been banging my head against the wall all afternoon... can anyone suggest any other possible causes for this error?

Thanks for any help.

Answer

Michael Berkowski picture Michael Berkowski · Oct 31, 2011

Run the GRANT statement with the IDENTIFIED BY:

GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%' IDENTIFIED BY '123456';