Tuesday, September 1, 2015

Problem running mysql client, cannot connect to mysql server

Edit3: Thanks for the help everyone. Sorry for wasting anybody's time, but it seems like a simple reboot solved it. I should've known better, but I just had the assumption that the "restart" solution is mostly valid just for MS Windows (no offense). I'll keep this in mind before I ask a question here again.







I installed the mysql-client-5.0 and mysql-server-5.0 packages on Ubuntu 8.04, using sudo apt-get install.



When I try to run the "mysql" command, I get the following error:



ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


To verify that mysql server is running, I tried this, and it does seem to be running, with the correct socket too:





$ ps aux | grep mysql
root 13388 0.0 0.0 1772 528 ? S 06:24 0:00 /bin/sh /usr/bin/mysqld_safe
mysql 13553 0.0 1.4 127012 15332 ? Sl 06:25 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
root 13555 0.0 0.0 3008 696 ? S 06:25 0:00 logger -p daemon.err -t mysqld_safe -i -t mysqld
ehsanul 16910 0.0 0.0 3092 772 pts/4 R+ 07:17 0:00 grep mysql


So I don't understand why I'm getting an error trying to connect to mysql server. Note that I'm completely new to mysql.




Edit:



As requested in comments, the exact command that is returning the error is simply "sudo mysql".
And when I check netstats for active networks services, I do see an entry for port 3306, with Protocol: tcp, IP Source: 127.0.0.1, State: LISTEN



Edit2:
It appears as if the /var/run/mysqld/mysqld.sock socket doesn't exist (if I'm interpreting the following output correctly):




$ ls -al /var/run/mysqld/
total 0

drwxr-xr-x 2 mysql root 40 2009-08-06 06:36 .
drwxr-xr-x 20 root root 860 2009-08-06 06:25 ..

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...