Troubleshooting access problems
Let's try to troubleshoot some connection issues.
We will encounter the following error if MySQL is not running or if it is running on any another machine and you have forgotten to specify the host with -h
:
$ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
The following error is similar to the one mentioned earlier as, in this case, the connection goes over TCP. This can happen if MySQL runs on a non-standard port, and you didn't specify the port with -p
:
$ mysql -h 127.0.0.1 ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
If we don't supply a password, we will encounter the following error:
$ mysql -h 127.0.0.1 ERROR 1045 (28000): Access denied for user 'jdoe'@'localhost' (using password: NO)
Here, we can reach MySQL, but we are not allowed in.
The solution is to add -p
and then...