Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt).
First login as root user. Now type the following command as per your Linux distro:
A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:
* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
/etc/init.d/mysqld restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start # service mysqld stop # service mysqld restart
(B) If you are using mysql on Debian / Ubuntu Linux then use following command:
* To start mysql server:
/etc/init.d/mysql start
* To stop mysql server:
/etc/init.d/mysql stop
* To restart mysql server
/etc/init.d/mysql restart -----------------------------------------------------------------------------------------------------------------
First, instead of running service mysqld start
or service mysqld restart
try running:
$ service mysqld stop; mysqld_safe &
There are known problems with the mysqladmin
lines in the /etc/init.d/mysqld
script.
If this isn’t working, try the following things: check if there is enough free disk space (especially in/var
):
$ df -h
Check for possible error messages in these files (not all of them may exist):
# tail -n 30 /var/log/messages
# tail -n 30 /var/log/mysqld.log
# tail -n 30 /var/lib/mysql/*.err
# tail -n 30 /var/log/mysql/error.log
Next up, make sure that /etc/my.cnf
uses…
socket=/var/lib/mysql/mysql.sock
…and that the directory /var/lib/mysql/
actually exists.
Set the correct permissions and ownerships:
# chown -R mysql.mysql /var/lib/mysql/
# chmod g+w /var/run/mysqld/
# chgrp mysql /var/run/mysqld/
Still not working? Try changing the bind-address in my.cnf
to 127.0.0.1 or 0.0.0.0, or comment out that line.
If you’re still out of luck, search for more information about mysql_install_db
and since your InnoDB database may be broken also look into set-variable=innodb_force_recovery=6