I have two sneaky conjectures on this one
CONJECTURE #1
Look into the possibility of not being able to access the /tmp/mysql.sock
file. When I setup MySQL databases, I normally let the socket file site in /var/lib/mysql
. If you login to mysql as root@localhost
, your OS session needs access to the /tmp
folder. Make sure /tmp
has the correct access rights in the OS. Also, make sure the sudo user can always read file in /tmp
.
CONJECTURE #2
Accessing mysql via 127.0.0.1
can cause some confusion if you are not paying attention. How?
From the command line, if you connect to MySQL with 127.0.0.1
, you may need to specify the TCP/IP protocol.
mysql -uroot -p -h127.0.0.1 --protocol=tcp
or try the DNS name
mysql -uroot -p -hDNSNAME
This will bypass logging in as root@localhost
, but make sure you have root@'127.0.0.1'
defined.
Next time you connect to MySQL, run this:
SELECT USER(),CURRENT_USER();
What does this give you?
- USER() reports how you attempted to authenticate in MySQL
- CURRENT_USER() reports how you were allowed to authenticate in MySQL
If these functions return with the same values, then you are connecting and authenticating as expected. If the values are different, you may need to create the corresponding user root@127.0.0.1
.