0

I have an ec2 instance, but when i run mysql, it gives me this error

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

Similarly, when i run

/etc/init.d/mysql start

Oct 31 11:29:16 domU-12-31-38-00-A8-62 /etc/init.d/mysql[5263]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

What is wrong?

meow
  • 27,476
  • 33
  • 116
  • 177

2 Answers2

2

I had this same problem on an ec2 instance. These instructions worked perfectly for me:


Redhat Enterprise Linux - RHEL 5 / 6 MySQL installation

Type the following command as root user:

yum install mysql-server mysql

Redhat Enterprise Linux - RHEL 4/3 MySQL installation

Type the following command as root user:

up2date mysql-server mysql

Start MySQL Service

To start the mysql server type the following command:

chkconfig mysqld on
/etc/init.d/mysqld start

Setup the mysql root password

Type the following command to setup a password for root user:

mysqladmin -u root password NEWPASSWORD

Test the mysql connectivity

Type the following command to connect to MySQL server:

$ mysql -u root -p
1

Well, maybe the server is not running? :)

At the bare minimum:

ps aux|grep [m]ysql

If this returns nothing, then MySQL is not running.

Troubleshoot by adding the following to the config file: log_error=/path/to/logfile

Till
  • 22,236
  • 4
  • 59
  • 89