Solve the Problem of mysql stop fail in Ubuntu

Source: Internet
Author: User

Solve the Problem of mysql stop fail in Ubuntu

I recently encountered a MySQL stop fail problem when I was studying mysql. Here I will write down the problem and the solution process, not how difficult it is, however, I did not find a valid Chinese webpage in the process of solving this problem, which wasted a lot of time. Here I will write down the solution process and hope to save some time for the later users to solve the same problem. Now, let's get started.

My operating system environment is Ubuntu 14.04, 64-bit. The MySQL installation process is as follows:

Because the MySQL configuration file has been changed, you need to restart MySQL. I use the following two commands to stop mysql:

Of course, I also tried service mysql stop on the Internet, and it is useless. After searching for multiple times, I finally found a solution in an English forum. There are also a lot of respondents who have provided "methods" on the issue page, and only one of them has provided a solution to solve my problem.

The problem is solved like this:

1. log on to mysql with the root permission and execute the following SQL statement:

Select User from mysql. user

Check whether there is a user named debian-sys-maint in the user table in the mysql database. Execute the preceding SQL statement and return the result on my machine, as shown in:

If the user debian-sys-maint does not exist in the returned result set of your query, You need to perform the Second Step. If the user debian-sys-maint exists, then you need to perform the third step.

2. Execute the SQL statement: CREATE USER 'debian-sys-maint' @ 'localhost' identified by 'Password'

I will briefly explain this SQL statement: create a user named debian-sys-maint and use the password of mysql for the user. How can we specify the value of the password field? Is it specified at will? No. The password field must be related to the file/etc/mysql/debian. the password of debian-sys-maint in cnf must be consistent. On my machine,/etc/mysql/debian. the content of the cnf file is as follows:

3. If the second step is executed, you can stop mysql successfully without executing step 3. The process of step 3 is as follows:

First, run the following SQL statement to check the value of the password field in the row where debian-sys-maint is located and the value of/etc/mysql/debian. whether the passwords of debian-sys-maint in cnf are the same,

Because the passwords in mysql are encrypted and stored, we cannot compare them at all. Because we need the same passwords, execute the following SQL statement:

Update user set password = PASSWORD ("password from/etc/mysql/debian. cnf") where User = 'debian-sys-maint'

Here, password from/etc/mysql/debian. cnf is the password corresponding to debian-sys-maint in the/etc/mysql/debian. cnf file. Do not make a mistake.

In this way, you can stop mysql successfully.

To put it another way, we usually use English to solve the problem. Chinese and things are mixed, and there is a lot of noise, which not only cannot help you solve the problem, but also brings it into the ditch, a waste of time.

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.