Service:no such service mysqld with MySQL on, off and restart

Source: Internet
Author: User

1. Causes of problems and solutions

Since the MySQL temp file directory was modified, the service mysqld restart following error occurred using the restart MySQL:

service: no such service mysqld

Cause of Error:
It is because we did not copy the MySQL control script Mysql.server to/etc/init.d/when we compiled and installed MySQL.

Copy the support-files/mysql.server from the installation directory of MySQL to/etc/init.d/and rename it to Mysqld. The copy command is as follows:

#我的mysql安装路径是:/usr/local/mysqlcp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

How the 2.service command works

Service commands, as the name implies, are commands for managing services in the Linux operating system. Can be used to start, shut down, and restart system services, as well as to display the current status of all system services.

However, the ability to operate with service commands is a system service that has already been registered as Linux. Window can also be registered as a system service. So how to register as a system service?

For example, download a new software from the Internet and install it on Linux. To register as a system service, I need to write a Shell service script file myself. How is this service script file written? If you do not understand the mechanism of the Servcie command, something will be missing. For example, I downloaded the Sphinx after installing to the server. I want to use the "service Sphinx start" Such a short command to manage, it must be registered as a system service, and some software source code package is not provided written script, sometimes you have to write one yourself. Fortunately, however, MySQL has its own service script that can be called by the Services command, which is the Mysql.server script above, and all we have to do is copy the MySQL service script to the/ect/init.d/directory and rename it to Mysqld.

What is the role of the service-related chkconfig command?
Service commands can quickly open and stop services in Linux, which is useful during debugging Chkconfig commands can quickly set up a service program that needs to be started automatically when booting.

The functions of both commands can be implemented in other ways, but they are more convenient and easier to maintain.

The usage of the Chkconfig command is no longer mentioned! Self-check online!

What is stored in the 3./ect/init.d/directory

In Linux, both directories,/ETC/INIT.D and/ETC/RC.D/INIT.D, are used to place service scripts, which generally do not exist at the same time because the functionality is the same. When Linux starts, the run level is set according to the Chkconfig command to determine if the program is started, and if so, go back to the service script in those directories and start the appropriate program.

4. How to turn on, turn off, and restart MySQL without using service

If MySQL is not registered as a system service, then we can use MySQL to provide us with some tools to open, close, restart MySQL. Of course, the MySQL service script operation on MySQL also calls these tools to complete. These tools are in the bin directory of the MySQL installation directory. Put a picture:

If we follow the above operation to register MySQL as a system service, using the service to turn on, close, restart MySQL is very convenient, the command is as follows:

#重启service mysqld restart#开启service mysqld start#关闭service mysqld stop

or run the service script mysqld or mysql.server:

#启动/etc/inint.d/mysqld start#关闭/etc/inint.d/mysqld stop#重启/etc/inint.d/mysqld restart

Not using the service how to turn on, off, and restart MySQL means that this does not use the Services script Mysql.server provided by MySQL to manage the turn on and off of MySQL. But we can use the following tools to complete.

Turn on MySQL:

/usr/Local/mysql/bin/mysqld--basedir=/usr/Local/mysql--datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/  Data/tencent_im. Err --pid-file=/usr/local/mysql/data/tencent_im. PID -- Socket=/tmp/mysql. Sock --port=3306        

A bit long, above is I paste the running MySQL process, you can also use PS view before you turn off MySQL, and copy it.

Or use Mysqld_safe to start MySQL:

mysqld_safe --user=mysql &

Turn off MySQL:

mysqladmin -u[username] -p[password] shutdown

To restart MySQL:
View MySQL service script mysql.server or mysqld, I found that restarting MySQL is also the first to shut down before booting. So there is no direct restart of the command, or obediently shut down first, then start it!

Of course, using the tools provided by MySQL to control the MySQL open and close, there should be other methods, I am not too clear at the moment, have to know the message to inform, thank you very much!

The difference between 5.mysql and mysqld

Mysqld (MySQL deamon) is a service-side program that is the main program for MySQL to provide services, and there are many other programs available, see the bin directory of the MySQL installation directory.

MySQL is a command-line client program for executing SQL statements!

Also note that we are accustomed to renaming MySQL service script Mysql.server to mysqld in the/etc/init.d/directory and registering MySQL as a system service.

Service:no such service mysqld with MySQL on, off and restart

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.