I have similar problem as here. The problem is that solution proposed there does not work for me:
Just for now I have users:
+----------+------------------------------------+
| user | host |
+----------+------------------------------------+
| root | 127.0.0.1 |
| root | localhost |
both without passwords (just for now. I know it is bad!).
I'm connecting to mysql using this command:
mysql -u root -h 127.0.0.1 --protocol=tcp
After I logged in, I get:
mysql -u root -h 127.0.0.1 --protocol=tcp
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.61-log Source distribution
Copyright (c) 2000, 2011, 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> \s
--------------
mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1
Connection id: 5
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.1.61-log Source distribution
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 2 days 9 hours 2 min 13 sec
Threads: 1 Questions: 102 Slow queries: 0 Opens: 19 Flush tables: 1 Open tables: 12 Queries per second avg: 0.0
--------------
mysql> SELECT USER(),CURRENT_USER();
+----------------+----------------+
| USER() | CURRENT_USER() |
+----------------+----------------+
| root@localhost | root@localhost |
+----------------+----------------+
1 row in set (0.00 sec)
mysql>
QUESTION:
How to login as 'root'@127.0.0.1?
localhost
is127.0.0.1
right? Its defined inhosts
that way.127.0.0.1
islocalhost
. This is true on lamost any operating system with traditional networking support. If I were to hazard a guess if you got rid of one of theroot
users both @127.0.0.1 and @localhost would still work.