0

I have an amazon ec2 instance running on the Amazon Linux AMI and its a micro instance. I wanted to install Django onto my server so I entered these commands

wget http://www.mlsite.net/blog/wp-content/uploads/2008/11/go
wget http://www.mlsite.net/blog/wp-content/uploads/2008/11/django.conf
chmod 744 go
./go

So after I was done, I ran sudo service httpd restart and sudo service mysqld restart

and This is what came up for mysqld:

Stopping mysqld:                                           [  OK  ]
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

So I deleted the django files /usr/local/python2.6.8/site-packages/django_registration.egg and I tried finding the error and I found out that in my /etc/my.cnf for the socket, it said socket=/var/lock/subsys/mysql.sock so I went to /var/lock/subsys/ and there was no mysql.sock. I tried creating one using vim but it still didn't work. Then I checked the error log and it said

120712 20:33:11 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
120712 20:33:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

UPDATE:

I entered these commands:

cd /var/lib/mysql/
touch mysql.sock
chmod +x mysql.sock
chown mysql:mysql -R *

And it still didn't work...

So I am pretty much lost right now. I know it has something to do with mysql.sock

If you might know a reason why this was caused could you please let me know? I have a wordpress site on my server, so i kind of need MySQL to work. Thanks!

7
  • 1
    You need to find out why mysqld failed to start. Check in your mysql or system logs. Once mysql is running there will be a /var/run/mysqld/mysqld.sock Oct 17, 2012 at 22:56
  • i can't check my mysql. every time I type mysql it says ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Oct 17, 2012 at 23:13
  • @ShalinShah Yes, we know that you're getting that error. Look through your logs to find out why.
    – Magellan
    Oct 17, 2012 at 23:18
  • 3
    Any particular reason you're not installing an official repo Django package?
    – Wesley
    Oct 17, 2012 at 23:31
  • Did you look over the script (go) that you ran? It makes several assumptions may not hold true on your setup. The notable one being an ebs volume on /dev/sda4 - which the scripts attempts to mount and then tries to move your MySQL directory to /mnt/ebs/mysql (it also changes your my.cnf accordingly). If you don't have the necessary EBS volume, my.cnf will have an invalid path in it. Revert the changes to /etc/my.cnf and hopefully MySQL will start. As an aside the script is trying to install Django 1.0 (current version is 1.4.2).
    – cyberx86
    Oct 18, 2012 at 1:32

3 Answers 3

4

Inspecting the go script you downloaded and executed, I found the following lines:

# Change the MySQL data directory
sed -e 's!/var/lib/mysql$!/mnt/ebs/mysql!' -i /etc/my.cnf

This effectively changes your mysql data directory (datadir setting), so you can't access any previously created database (like the wordpress database).

As a wild guess, I would think that the mysqld can't access /mnt/ebs/mysql and therefore doesn't start. Try to change it back to /var/lib/mysql. However, this might interfere with your django. If you get the django configured mysql to run, you can always add a second my.cnf with another name and other tcp port and run two MySQL servers with different configurations.

The socket error message is about the MySQL server not running. Do not try to emulate the socket by putting a file in its way.

The go script also makes some more changes to my.cnf that could be a problem. Have a look at the go file yourself and try to undo the changes made.

If nothing of the above helps, you can try to start the mysqld process from command line by hand, using the same arguments as the service script does, plus an added --verbose and post its output.

0
0

Ok, I figured it out thanks to @escitalopram so I will accept his answer! Ok, django changed my MySQL data directory from /var/lib/mysql to /mnt/ebs/mysql in my /etc/my.cnf, so in my /etc/my.cnf, it said

datadir=/mnt/ebs/mysql and I changed it to datadir=/var/lib/mysql. And everything worked fine. I restarted MySQL hoping for the red [FAILED] message but I got an [OK]. Also, my socket was messed up in /etc/my.cnf but I had already fixed that!

-1

i had the same situation on amazon e2c server

i did the same:

 cd /var/lib/mysql/
    sudo touch mysql.sock
    sudo chmod +x mysql.sock
    sudo chown mysql:mysql -R *

reboot the server,
then:

sudo /etc/init.d/mysqld start

check mysql:

mysql -u root -p

note, this will not fix the problem. but it will give you the chance to access the data and move to a reliable server

You must log in to answer this question.

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