I'm trying to access mysql and when I run the mysql command, I get the following.
[root@ip-10-229-65-166 tpdatabase-1.8.0.28356]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Doing this returns nothing
[root@ip-10-229-65-166 mysqld]# find -name mysql*
[root@ip-10-229-65-166 mysqld]# /etc/init.d/mysql stop -bash: /etc/init.d/mysql: No such file or directory
[root@ip-10-229-65-173 tpdatabase-1.8.0.28356]# mysql_config |grep -- --socket
--socket [/var/lib/mysql/mysql.sock]
Maybe a permissions problem?
I do have mysql installed using yum install mysql
I'm running CentOS 5.4 on a Amazon EC2 Cloud Instance
sock is created by the mysql daemon on start, and it is removed (or, becomes un-connectable) if this daemon stops. This message is given by some client process, trying to connect your mysqld on this socket without success. Its most likely reason is that the mysqld doesn't run.
The default location for the Unix socket file that the server uses for communication with local clients is /tmp/mysql. sock . (For some distribution formats, the directory might be different, such as /var/lib/mysql for RPMs.)
If you run into this error message while trying to connect to a local MySQL Server: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' It means either the MySQL server is not installed/running, or the file mysql.
You need to install the server package:
sudo yum install mysql-server
After installation, you have to start the service:
sudo service mysqld start
rm -rvf /var/lib/mysql/ib_logfile* touch /var/lib/mysql/mysql.sock touch /var/lib/mysql/mysql.pid chown -R mysql:mysql /var/lib/mysql systemctl restart mysql
try this and check the permission of both /var/lib/mysql/mysql.sock and /tmp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With