LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Cannot start MySQL server (http://www.linuxquestions.org/questions/linux-server-73/cannot-start-mysql-server-4175429623/)

lenka 09-29-2012 12:35 PM

Cannot start MySQL server
 
I was trying to install Zend Guard Loader and made some errors so had to reinstall php (see this thread).

Now I have installed php and it's working with apache but I cannot start my MySQL server. It's installed and up to date, but when I try to start or run mysql I get the following error messages:

Code:

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

Code:

/var/run$ start mysql
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.6" (uid=1000 pid=14759 comm="start mysql ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")

Code:

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

There is nothing in my /var/log/mysql/error.log from when I try to do this.

I don't have any /var/run/mysqld/ folder - should I have?

ANy idea where I can check for error messages or how to fix the problem? Should I reintstall mysql?

pingu 09-29-2012 01:54 PM

First guess is you're using wrong command.
To me it looks like you're trying to start a mysql client, to start the server it should be something like "service mysql.server start" or "/etc/init.d/mysql.server start".
You're on Ubuntu which uses "Upstart", I never used it but maybe try "mysql.server start"

lenka 09-29-2012 02:30 PM

Quote:

Originally Posted by pingu (Post 4792684)
First guess is you're using wrong command.
To me it looks like you're trying to start a mysql client, to start the server it should be something like "service mysql.server start" or "/etc/init.d/mysql.server start".
You're on Ubuntu which uses "Upstart", I never used it but maybe try "mysql.server start"

No, sorry, this above command doesn't exist, and I have tried sudo mysql start and sudo start mysql and sudo /etc/init.d/mysql start

But it seems like I am missing the /var/run/mysqld folder including the mysqld.sock

Question is whether I should reinstall mysql or can it be fixed somehow.

pingu 09-29-2012 02:48 PM

mysql is the *client*, you need to start the *server*.
Look at it:
Code:

/var/run$ mysql start
ERROR 2002 (HY000): Can't connect to local MySQL server

As I read this, mysql client can't connect to mysql server.
So, you need to find the correct command to start the server.
Unfortunately I don't have any Ubuntu around so I can't check it further right now.
What mysql-related service do you find in /etc/init.d?

If your command actually should start the server then a few suggestions:
1) Check under which user the server is suppposed to run.
2) Check permissions to the mysql direcory - /var/lib/mysql?
3) Check /var/log/messages, with a bit of luck you get some more info there.

pingu 09-29-2012 02:49 PM

... and YES it can be fixed!
Even though I don't know what causes the problem I'm very very sure it can be fixed.

pingu 09-29-2012 03:02 PM

And of course, check the disk-space!

lenka 09-29-2012 03:16 PM

Quote:

Originally Posted by pingu (Post 4792726)
mysql is the *client*, you need to start the *server*.
Look at it:
Code:

/var/run$ mysql start
ERROR 2002 (HY000): Can't connect to local MySQL server

As I read this, mysql client can't connect to mysql server.
So, you need to find the correct command to start the server.
Unfortunately I don't have any Ubuntu around so I can't check it further right now.
What mysql-related service do you find in /etc/init.d?

If your command actually should start the server then a few suggestions:
1) Check under which user the server is suppposed to run.
2) Check permissions to the mysql direcory - /var/lib/mysql?
3) Check /var/log/messages, with a bit of luck you get some more info there.

Ahh ... I wasn't aware of the difference client/server. But when I google ubuntu and start mysql server, I get that it's the /etc/init.d/mysql that is the right command (or just mysql) - that is the way I have always started and stopped it as well.

I do have a mysql command in my /etc/init.d ... and that is the only mysql-related command.

I get this in my /var/log/messages - they are from the 25th - I think that was just before I tried to install zend and messed up:
Code:

tail /var/log/messages
Sep 25 09:18:56 rs202400 kernel: [81392.579942] type=1505 audit(1348557536.722:24):  operation="profile_replace" pid=23378 name="/usr/sbin/mysqld"
Sep 25 09:18:56 rs202400 kernel: [81392.662645] type=1505 audit(1348557536.812:25):  operation="profile_replace" pid=23434 name="/usr/sbin/named"
Sep 25 09:18:56 rs202400 kernel: [81392.674216] type=1505 audit(1348557536.822:26):  operation="profile_replace" pid=23433 name="/usr/sbin/mysqld"
Sep 25 09:18:56 rs202400 kernel: [81392.678629] type=1505 audit(1348557536.822:27):  operation="profile_replace" pid=23377 name="/sbin/dhclient"
Sep 25 09:18:56 rs202400 kernel: [81392.678791] type=1505 audit(1348557536.822:28):  operation="profile_replace" pid=23377 name="/usr/lib/NetworkManager/nm-dhcp-client.action"
Sep 25 09:18:56 rs202400 kernel: [81392.678869] type=1505 audit(1348557536.822:29):  operation="profile_replace" pid=23377 name="/usr/lib/connman/scripts/dhclient-script"
Sep 25 09:18:56 rs202400 kernel: [81392.797279] type=1505 audit(1348557536.942:30):  operation="profile_replace" pid=23432 name="/sbin/dhclient"
Sep 25 09:18:56 rs202400 kernel: [81392.797410] type=1505 audit(1348557536.942:31):  operation="profile_replace" pid=23432 name="/usr/lib/NetworkManager/nm-dhcp-client.action"
Sep 25 09:18:56 rs202400 kernel: [81392.797476] type=1505 audit(1348557536.942:32):  operation="profile_replace" pid=23432 name="/usr/lib/connman/scripts/dhclient-script"
Sep 25 09:19:40 rs202400 kernel: Kernel logging (proc) stopped.


pingu 09-29-2012 04:12 PM

"I do have a mysql command in my /etc/init.d ... and that is the only mysql-related command."
OK, I surrender on the first part- "start mysql" should start the server.

How about the other 3 things - user, permissions & disk-space?

lenka 09-30-2012 03:06 AM

Disk space is not problem, it's a whole new server (I wanted to use it for testing - I have another one with same specs as my live server, but got tired of messing up the live server :-D)

Code:

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2      854G  20G  791G  3% /
udev            7.9G  4.0K  7.9G  1% /dev
tmpfs          3.2G  232K  3.2G  1% /run
none            5.0M    0  5.0M  0% /run/lock
none            7.9G    0  7.9G  0% /run/shm
none            4.0T    0  4.0T  0% /media/psf

Premissions for /var/lib/mysql:
Code:

drwx------ 6 mysql  mysql  4096 Sep 30 10:00 mysql
Should be OK, right? (I am am wondering about the date though? Isn't it the date for last change? It's the current date/time everytime I check, even though I am not using mysql right now).

User - how to check that? I have access to root server and have just one user (my own) besides that atm.

I still thing it's fishy that I don't have any mysqld.sock file - nor a /var/run/mysqld folder. I am thinking that maybe the zend instalattion could have removed it somehow?

pingu 09-30-2012 03:25 AM

The /var/run/mysqld folder and the files below it are created when the mysql server starts.
The files are deleted when mysql stops, but the directory is not, AFAIK. However, if the directory doesn't exist it is simply created by the mysql startup process (tested on my Debian Lenny).

Check your /etc/mysql/my.cnf, the user for mysql is specified there as well as other settings.

On my 'puter, the databases are in /usr/local/share/mysql/ not in /var/lib/mysql - but that might be configured manually.
Anyway, check that /var/lib/mysql/ contains the databases.

Do you have any mysql-logs under /var/log?
The place for logging might be in my.cnf (grep log /etc/mysql/my.cnf)

pingu 09-30-2012 03:39 AM

I see now you mentioned /var/log/mysql/error.log in your first post.
No other logfiles there?

One thing I remember happened to me some time ago:
mysql couldn't start (don't remember error message), I deleted the "ib_logfile#" in mysql database directory, then mysql started.

Also I read on some forums that you could try start the daemon directly to get more info what's going on.
#/usr/bin/mysqld
(well, normally it's in /usr/bin, you shouldn't need the path though).

lenka 09-30-2012 04:15 AM

Quote:

Originally Posted by pingu (Post 4793082)
The /var/run/mysqld folder and the files below it are created when the mysql server starts.
The files are deleted when mysql stops, but the directory is not, AFAIK. However, if the directory doesn't exist it is simply created by the mysql startup process (tested on my Debian Lenny).

Ah, I see. That makes sense.

Quote:

Originally Posted by pingu (Post 4793082)
Check your /etc/mysql/my.cnf, the user for mysql is specified there as well as other settings.

User is set to mysql

Quote:

Originally Posted by pingu (Post 4793082)
On my 'puter, the databases are in /usr/local/share/mysql/ not in /var/lib/mysql - but that might be configured manually.
Anyway, check that /var/lib/mysql/ contains the databases.

Do you have any mysql-logs under /var/log?
The place for logging might be in my.cnf (grep log /etc/mysql/my.cnf)

Ahaaaa!!! It's now up and running! I had bad premissions in one of my databases which I just copied recently. I changed the premissions and suddently mysql was up and running by it self! Could it be that it has been trying to connect all along automatically?

Anyway - problem is solved. Thank you so much for your patience and your help!


All times are GMT -5. The time now is 03:26 PM.