Need help?

Our experts will login to your server within 30 minutes to fix urgent issues.

Customer support or server support, make your own solution using our support configuration wizard.

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

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 Dedicated 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 Hosting 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/ --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 Hosting Support Engineers do the following commands from the Mysql prompt of the server.

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

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.



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 Dedicated Support Engineers fix it.


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.



Submit a Comment

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

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.

Related Posts