0

I have an ubuntu server with mysql installed, at one point I saw the php code running on the server could access mysql but I can't access mysql remotely, for another server or sequal pro.

$ mysql -u root -p
mysql> GRANT ALL on *.* TO 'thomas'@'%';
mysql> exit
$ mysql -u thomas -p
mysql> show grants;
+------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for thomas@localhost                                                                                                              |
+------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'thomas'@'localhost' IDENTIFIED BY PASSWORD '[ENCRYPTEDPASSWORD]' WITH GRANT OPTION |
+------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> exit
$ mysql -u thomas -p -h [SERVERIP]
ERROR 1045 (28000): Access denied for user 'thomas'@'[SERVERNAME]' (using password: YES)

Update:

I wen't in and dropped all the users that where made (some didn't have passwords) I was going by the mysql.user table and using the drop user command.

CREATE USER 'thomas'@'localhost' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON *.* TO 'thomas'@'localhost' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON *.* TO 'thomas'@'[SERVERIP]' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON *.* TO 'thomas'@'%' IDENTIFIED BY '[PASSWORD]';

the table now looks like this:

+--------------+------------------+
| Host         | User             | 
+--------------+------------------+
| localhost    | root             | 
| localhost    | phpmyadmin       | 
| 127.0.0.1    | root             | 
| ::1          | root             | 
| localhost    | debian-sys-maint | 
| localhost    | thomas           | 
| [SERVERIP]   | thomas           | 
| %            | thomas           | 
+--------------+------------------+
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424

1 Answers1

2

Well, you have

GRANT ALL PRIVILEGES ON *.* TO 'thomas'@'localhost'

but you are not on localhost. You might want to try

GRANT ALL PRIVILEGES ON *.* TO 'thomas'@'%'

Ofcourse you have to add IDENTIFIED BY 'password' if you so desire

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92