I really can't figure out this. Under a certain user, I am able to connect to the MySQL db on machine A from machine B, but I can't connect locally from machine A itself or connect from PHP.
To illustrate, I created a db MYTEST on machine A. Then I create a user MYTEST and grant all privileges on MYTEST:
GRANT ALL PRIVILEGES ON MYTEST.* TO 'MYTEST'@'%' IDENTIFIED BY 'mypass';
FLUSH PRIVILEGES;
I did these as root, which I can connect from anywhere without any problem. Result:
Then, I try to connect from another machine, machine B:
ubuntu@ip-*-*-2-153:~$ mysql -u MYTEST -p -h *.*.*.174
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 84
Server version: 5.5.32-0ubuntu7 (Ubuntu)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
These all look good. Now I go back to machine A and do this:
root@wangboyang:~# mysql -u MYTEST -p
Enter password:
ERROR 1045 (28000): Access denied for user 'MYTEST'@'localhost' (using password:
YES)
root@wangboyang:~#
Whereas I'm able to connect as root:
root@wangboyang:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Ultimately, I need to connect from PHP. It doesn't work either:
php > $con = mysqli_connect('128.199.253.174', 'MYTEST', 'mypass');
PHP Warning: mysqli_connect(): (28000/1045): Access denied for user 'MYTEST'@'w
angboyang.com' (using password: YES) in php shell code on line 1
I have to use root:
php > $con = mysqli_connect('128.199.253.174', 'root', 'somepasswordhere');
php >
I then tried something aggressive. I granted all global privileges to MYTEST, but all the results remained the same. Please anyone has any idea? Would Really appreciate it.
Note:
I'm sure the password is correct. To confirm this I used the same password as the root and compared the hash to be the same. I can connect using root. So the password is correct.
Both machines Ubuntu 13.10.
I tried to flush privileges and restart mysql server in between all these steps but to no avail.