An odd problem: Can't connect to local MySQL via TCP
Then I connect to MySQL via UNIX Socket, make sure 'root'@'127.0.0.1' exists:
> mysql> show grants for 'root'@'127.0.0.1';
+–--------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@127.0.0.1 |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON . TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD '*836E5321B6F5B6371002741B5CA03AC8CEA9418A' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
But when I connect to MySQL via TCP:
> root@castle /v/l/mysql# mysql -u root -h 127.0.0.1 -p 1
Enter password:
ERROR 1130 (HY000): Host 'castle.abcdefg.org' is not allowed to connect to this MySQL server
'castle.abcdefg.org' is FQDN of this machine. If I create a new user, 'root'@'106.186.125.xyz', connection is ok:
> root@castle /v/l/mysql# mysql -u root -h 127.0.0.1 -p 1
Enter password:
mysql> status;
–------------
mysql Ver 14.14 Distrib 5.6.22, for Linux (x86_64) using EditLine wrapper
Connection id: 7
Current database:
Current user:
root@castle.abcdefg.org SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 5.6.22 MySQL Community Server (GPL)
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 36 min 0 sec
Threads: 2 Questions: 80 Slow queries: 0 Opens: 87 Flush tables: 1 Open tables: 80 Queries per second avg: 0.037
mysql> select current_user();
+----------------------+
| current_user() |
+----------------------+
|
root@106.186.125.xyz |+----------------------+
1 row in set (0.00 sec)
So the problem is, when I connect to local MySQL server, MySQL check eth0 ip instead of 127.0.0.1. How does it happen and how to solve this problem?