LINUX starts and restart and stop MYSQL command of

  • 2020-05-13 04:15:02
  • OfStack

How do I start/stop/restart MySQL

1. Startup mode

1. Start with service: service mysqld start

2, start using mysqld script: / etc/inint d/mysqld start

3. Start with safe_mysqld: safe_mysqld &

2. Stop

1. Start with service: service mysqld stop

2, start using mysqld script: / etc/inint d/mysqld stop

3, mysqladmin shutdown

3. Restart

1. Start with service: service mysqld restart

2, start using mysqld script: / etc/inint d/mysqld restart

When I first learned mysql, I used redhat. What is start/rc. d/init. d/start

It was easy, but I learned more and more about it later. Some versions of mysql were too low, while others were with the system

I want to install the lower version of mysql required by web service

Later, I learned to install mysql in the way of tar. My mysql was installed in the directory /usr/local/mysql

We've had a lot of problems. The most common are:

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

Solutions:

[root@test mysql]# /usr/local/mysql/bin/mysqladmin -u root /
> -S /var/lib/mysql/mysql.sock password 'your.passwd'

Or make a connection

ln -s /var/lib/mysql/mysql.sock /tmp

In fact, you can't find /tmp/ mysql. sock is sometimes not /tmp directory does not have this file, is launched

The orders are wrong. I've been there

There are several common ways of starting, and you don't remember them very well, if you're sure that tmp has mysql.sock

Try a few more commands

/usr/local/mysql/bin/mysql -u root -p
/usr/local/mysql/bin/mysqld --user=mysql &
/usr/local/mysql/bin/mysqld --user=root &
/usr/local/mysql/bin/mysqld_safe --user=root &
/usr/local/mysql/bin/mysqld_safe --user=mysql &
/usr/local/mysql/bin/safe_mysqld--uer=root & (note that safe_mysqld is different from mysqld_safe, & That means mysql is running in the background.) mine will give you an error
STOPPING server from pid file
/usr/local/mysql/data/localhost.localdomain.pid
060304 11:46:21 mysqld ended

This is a permission issue. My mysql directory belongs to root users, and also belongs to root group. If I start mysqld_safe, I will have no problem.

Just pay attention to these: mysql,safe_mysqld,mysqld_safe,mysqld,mysqladmin. Try again

In fact, sometimes mysql has started normally, check to see if mysql starts the command

ps -aux | grep mysqld

You'll see something like this

mysql 6394 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/
mysql 6395 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/
mysql 6396 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/
root 6422 0.0 1.1 2408 732 pts/3 S 16:20 0:00 grep
mysql

See if mysql is listening for port commands
netstat -tl | grep mysql
You'll see something like this
tcp 0 0 *:mysql *:* LISTEN


Related articles: