I set up a Digital Ocean droplet (server) a few days ago and need to access mysql. No password for root is working amongst what I've tried. However this command:

service mysql[d] stop

Doesn't work. Apparently I am supposed to issue this command:

sudo systemctl stop mariadb.service

But that results in

Failed to stop mariadb.service: Unit mariadb.service not loaded.

Furthermore, this command

mysqld_safe --skip-grant-tables --skip-networking & mysql -u root

Results in these responses:

sudo: mysqld_safe: command not found
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[1]+  Exit 1   sudo mysqld_safe --skip-grant-tables --skip-networking

I am logged into the server as root; what do I do from here?

  • First you need to remember whether you installed MySQL, or MariaDB, or as seems likely, neither. – Michael Hampton Dec 5 '16 at 17:54
  • What is the output from these command? 'rpm -qa | grep mariadb' and 'rpm -qa | grep mysqld' and 'rpm -qa | grep mysql' – Anthony Fornito Dec 5 '16 at 20:21
  • Thanks @AnthonyFornito, the output from the mariadb was mariadb-5.5.50-1.el7_2.x86_64 mariadb-libs-5.5.50-1.el7_2.x86_64 and the output from mysql was php-mysql-5.4.16-36.3.el7_2.x86_64 - mysqld returned nothing. – Oliver Williams Dec 6 '16 at 19:31
  • @MichaelHampton - it appears I have BOTH on my server. – Oliver Williams Dec 6 '16 at 19:32
  • Really? I only see MariaDB there. – Michael Hampton Dec 6 '16 at 19:46


yum remove mysql

Then try

service mariadb restart

Then look at the out from

service mariadb status

You should see it running then the commands your tried early should work


 yum remove mysql

does not work Try

 chkconfig mysql off

Reboot and try to start maria again.

  • No success with the first part. I got: [root@centos-8gb-nyc2-01 ~]# service mariadb restart -- Redirecting to /bin/systemctl restart mariadb.service -- Failed to restart mariadb.service: Unit mariadb.service failed to load: No such file or directory. [root@centos-8gb-nyc2-01 ~]# service mariadb status Redirecting to /bin/systemctl status mariadb.service ● mariadb.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) – Oliver Williams Dec 6 '16 at 19:46
  • ckconfig only results in a -bash: command not found error. – Oliver Williams Dec 6 '16 at 19:46
  • chkconfig <-- forgot the h – Anthony Fornito Dec 6 '16 at 19:51
  • After reboot try yum install mariadb – Anthony Fornito Dec 6 '16 at 19:52
  • chkconfig only works on sysv services You need to use systemctl enable. – user9517 Dec 6 '16 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.