1

I've been trying so hard just to connect with MySQL in my Linux server account. However when I run mysqladmin -u root -p, it generates this prompt:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

Then when I tried this:

mkdir /var/run/mysqld
touch /var/run/mysqld/mysql.sock

it will prompt

touch: cannot touch `/var/run/mysqld/mysql.sock': Permission denied

Can anyone help me if there is any workaround or a solution for this?

1
  • Have you ensured MySQL server is running? Have you tried editing the file as root? Commented Aug 5, 2014 at 7:39

1 Answer 1

0

Don't try to touch the file. It's not up to you to do that.

Your MySQL server doesn't appear to be running. How to start it depends on your Linux distribution (Debian? Gentoo? Red Hat?), but it's probably something like

sudo /etc/init.d/mysql start

or

sudo service mysql start

Then try again.

It may also be the case that MySQL isn't listening on a UNIX socket. Try to run

mysql -h localhost -u root -p

(I am assuming myadmin is a typo in your message; you probably meant mysqladmin or similar)

2
  • :it seems like I cannot use the sudo command since I don't have sudo password.
    – Kim
    Commented Aug 5, 2014 at 8:00
  • The sudo password is your user's password. I assumed you had root rights on that server - don't try to sudo if we're talking about shared hosting! Is this the case? Or is this a Linux machine under your control? Commented Aug 5, 2014 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .