PDA

View Full Version : How do i restart mySQL?


TB2
Sun 4th Jun '00, 6:55am
Hi,

mySQL on my server worked fine till yet, now i've got this error:

ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock'(2)

Is there any chance to restart mySQL via telnet?

Thanx for hints!

bira
Sun 4th Jun '00, 7:51am
I just had the exact same problem a few minutes ago :(

Since I didn't have a clue what to do, I just restarted the server and everything's back to normal.

But if someone knows of a cronjob that will make sure MySQL is always up (or rather the mysqld or whatever it is), I'd appreciate it.

TB2
Sun 4th Jun '00, 8:20am
Originally posted by bira
I just had the exact same problem a few minutes ago :(

Since I didn't have a clue what to do, I just restarted the server and everything's back to normal.


This was my first thought and i used apache_restart on telnet ... my server restarts fine ... but mySQL isn't there ... :(

bira
Sun 4th Jun '00, 8:44am
I mean I actually rebooted the whole damn thing :)

TB2
Sun 4th Jun '00, 8:50am
bira, this means you've got the possibility to put a finger onto your reset button ... :D

For this my finger must be about 700 miles long ....

;)

wandrer
Sun 4th Jun '00, 10:32am
linux:~$ mysqladmin ping
mysqld is alive
linux:~$

That will show you if mysqld is alive and kicking...

bira
Sun 4th Jun '00, 5:41pm
wanderer, let's take it a step further. What happens when it's not alive?

(and I can see if it's running or not via top as well).

wandrer
Sun 4th Jun '00, 8:39pm
From the manual located at:

http://www.mysql.com/Manual_chapter/manual_toc.html#Automatic_start

=====

4.15.3 Starting and stopping MySQL automatically

The mysql.server script can be used to start or stop the server, by invoking it with start or stop arguments:

shell> mysql.server start
shell> mysql.server stop

mysql.server can be found in the `share/mysql' directory under the MySQL installation directory, or in the `support-files' directory of the MySQL source tree.

Before mysql.server starts the server, it changes directory to the MySQL installation directory, then invokes safe_mysqld. You might need to edit mysql.server if you have a binary distribution that you've installed in a non-standard location. Modify it to cd into the proper directory before it runs safe_mysqld. If you want the server to run as some specific user, you can change the mysql_daemon_user=root line to use another user. You can also modify mysql.server to pass other options to safe_mysqld.

mysql.server stop brings down server by sending a signal to it. You can take down the server manually by executing mysqladmin shutdown.

You might want to add these start and stop commands to the appropriate places in your `/etc/rc*' files when you start using MySQL for production applications. Note that if you modify mysql.server, then if you upgrade MySQL sometime, your modified version will be overwritten, so you should make a copy of your edited version that you can reinstall.

If your system uses `/etc/rc.local' to start external scripts, you should append the following to it:

/bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld &'

You can also add options for mysql.server in a global `/etc/my.cnf' file. A typical `/etc/my.cnf' file might look like this:

[mysqld]
datadir=/usr/local/mysql/var
socket=/tmp/mysqld.sock
port=3306

[mysql.server]
user=mysql
basedir=/usr/local/mysql

The mysql.server script uses the following variables: user, datadir, basedir, bindir and pid-file.

See section 4.15.4 Option files.

bira
Sun 4th Jun '00, 11:56pm
The SERVER is still running. It's the mysqld that crashes and needs to be restarted.

wandrer
Mon 5th Jun '00, 12:38am
It's the mysqld that crashes and needs to be restarted.

To get mysqld running, this is what I type:

linux:/usr/local/mysql/bin# ./mysql.server start
Starting mysqld daemon with databases from /usr/local/mysql/var
linux:/usr/local/mysql/bin#

That starts the mysqld daemon and finds the databases located in its config file.

werehere
Mon 5th Jun '00, 12:53am
You *should* be able to use mysqladmin shutdown to stop all, then use the commands posted by wandrer above to restart it.

bira
Mon 5th Jun '00, 2:49am
a few minutes ago I experienced the 4th crash in 24 hours. Does anyone know why it crashes so much? :(

wandrer
Mon 5th Jun '00, 3:00am
Normally, mysql is a very solid package. It sometimes 'crashes' when server load gets too high and it is stopped by the system. What is your server load when it 'crashes' ?

werehere
Mon 5th Jun '00, 3:01am
What do you mean by crash? We have not had any problems with the actual software crashing at all. Is there a specific error displayed? Is it using all of the Ram on the server and crashing? What is your setup?

Any other helpfull hints to go off of?:)

werehere
Mon 5th Jun '00, 3:05am
Yeah MySQL seems to be very solid as far as I can tell. When it does get overloaded and crashes it seems to be directly related to the amount of resources it is consuming and the OS not stopping it when necessary. Of course this (for us) was because we did not configure it properly and we were telling it that it could use more Ram than was available :p

It also seems to be vary stable, and has not corrupted the database in our case at all.