Bobcares

How to fix “Stopping mysql database server: mysqld failed!” error ?

by | Dec 4, 2018

Database servers functions as the backbone for websites. They need continuous updates to avoid performance problems.

After any configuration change, MySQL server needs a restart to bring the changes into effect. And, sometimes this restart can fail with errors like “Stopping mysql database server: mysqld failed!

At Bobcares, we help server owners to fix MySQL server errors as part of our Support Services for Web Hosts.

Today, let’s discuss on the top causes for this error and how we fix it.

 

What causes “Stopping mysql database server: mysqld failed!” error?

MySQL server often needs restart in various situations like data migration, version upgrade, etc. And, the changes will be effective, only if the restart is successful.

Recently, in a Debian server, mysqld failed to restart after copying the databases. The typical error message was :

# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld failed!
Starting MySQL database server: mysqld already running.
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

Here, it showed an additional error that there was access restriction for the MySQL user. Since, there was a part that stated “using password: YES“,  it means that the password was correct. But, server did not accept this password.

Let’s see, what went wrong here.

In Debian servers, there is a special MySQL user called “debian-sys-maint“.

During the installation, MySQL generates a random password for “debian-sys-maint” and stores its credentials inside the file /etc/mysql/debian.cnf. It also stores the user’s details in the “users” table in the database too.

But, when we do actions like copying databases to another server, upgrade the MySQL installation, etc., there are chances that these passwords may differ. This results in the error “Stopping mysql database server: mysqld failed!“.

 

How to fix the error ?

To fix the error, we need to fix the password mismatch of the database user. Hence, our Support Engineers do the following:

1. Check the status of MySQL

Before debugging further, we need to check whether MySQL service is running on the server or not.

If the mysqld process is running, the output will be :

ps aux | grep mysql 
root      2045  0.0  0.1   2676  1332 ?        S    Jun25   0:00 /bin/sh /usr/bin/mysqld_safe
mysql     2082  0.6 10.7 752544 111188 ?       Sl   Jun25  18:49 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock

Here, we note down the process id of the working mysqld process. In this case, the process id is “2082”.

We can simply stop the mysqld process by using the “Kill” command. But, this often causes the loss of data, particularly if an actual write happens in the database. So we avoid doing this in normal situations.

 

2. Check the MySQL root password

Secondly, we check and confirm that we can connect to the MySQL server using root password. For this, we use :

mysql -p -u root password 'mypassword'

If there is problem with the root user password, we reset the password. This ensures MySQL connectivity on the server.

 

3. Fix mysql password for “debian-sys-maint”

Now, if there is no problem with the root mysql user, we need to check the password for MySQL user “debian-sys-maint”.

To view the current password for this user, we check the file /etc/mysql/debian.cnf

In order to fix the mismatch, our Support Engineers do the following commands from the Mysql prompt of the server.

>  SET PASSWORD FOR 'debian-sys-maint'@'localhost' = PASSWORD('mypassword');
>  FLUSH PRIVILEGES;
>  QUIT

Here, “mypassword” is the new password set. After changing the password, we do a MySQL restart again using:

/etc/init.d/mysql restart

And it works fine.

 

Conclusion

Stopping mysql database server: mysqld failed!” is an error that occurs mainly due to wrong MySQL user password. Today, we’ve seen the causes for the error and how our Support Engineers fix it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

2 Comments

  1. Emad Saeed

    followed the guide but didn’t solve my problem

    Reply
    • Sijin George

      Hello Emad,
      Can you please confirm if you are able to find the MySQL process currently running on the server. Looks like this needs further investigation. We’ll be happy to talk to you on chat (click on icon at right-bottom)

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF