0

I try to stop mysql but anything I do nothing happens

I checked my database:

~$ mysql --version
mysql  Ver 15.1 Distrib 10.0.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

It shows that Im using MariaDB ok... So I tried to stop it and...

$ sudo systemctl stop mariadb
Failed to stop mariadb.service: Unit mariadb.service not loaded.

mariadb.service not loaded? why?

I tried to stop database with this command:

sudo systemctl stop mysql

I got no error.

but my website still works. It means database is running.

when I print out status of mysql:

   Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since wto 2018-04-24 00:32:29 CEST; 9min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2062 ExecStop=/etc/init.d/mysql stop (code=exited, status=1/FAILURE)
  Process: 1988 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mysql.service
           ├─1459 /bin/bash /usr/bin/mysqld_safe
           ├─1608 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-file=/var/r
           └─1609 logger -t mysqld -p daemon error

kwi 24 00:32:29 bla-Z68A-D3H-B3 mysql[2062]:  * Stopping MariaDB database server mysqld
kwi 24 00:32:29 bla-Z68A-D3H-B3 mysql[2062]:    ...fail!
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: mysql.service: Control process exited, code=exited status=1
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: mysql.service: Unit entered failed state.
kwi 24 00:32:29 bla-Z68A-D3H-B3 systemd[1]: mysql.service: Failed with result 'exit-code'.
kwi 24 00:33:21 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:36:51 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:40:27 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.
kwi 24 00:40:31 bla-Z68A-D3H-B3 systemd[1]: Stopped LSB: Start and stop the mysql database server daemon.

My question is how can I stop mysql database.

Im getting this error

#1045 - Access denied for user 'skni'@'localhost' (using password: YES)

I found solution that to fix it I need first stop database

Anna K
  • 1,666
  • 4
  • 23
  • 47
  • Some ideas here [from this question](https://stackoverflow.com/a/11091462/243245)) but it sounds like you've tried them. It might be worth rebooting the system that might put it back into a responds-to-stop-commands state, but there's a small risk of a bad shutdown of the database. Absolute worst case you could reboot the machine into single user mode and you should have the system in a state where the server is stopped, but there's almost certainly better ways to do this. Good luck! – Rup Apr 23 '18 at 22:53
  • Thaks, One question... if I call command: "sudo dpkg-reconfigure mariadb-server-*.*" will it erase all my databases? Or It only change password? – Anna K Apr 23 '18 at 23:00
  • It really shouldn't erase your databases, but I'm not 100% sure sorry. Is the database working well enough to mysqldump your databases or back them up first? – Rup Apr 23 '18 at 23:03

1 Answers1

1
mysql --version

says gives the commandline tool's is version. It says nothing about whether mysqld (the 'server') is running.

This might be more informative:

mysqladmin -u root status

where you use sufficient credentials (user/password/host/port) to actually connect to the server.

#1045 - Access denied for user 'skni'@'localhost' (using password: YES)

Says that user 'skni' is not allowed to connect with the password used. This is a login problem, not a server start/stop problem. The server must be running for that message to occur.

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • "mysql --version says gives the commandline tool's version" - agreed, although chances are if you've just installed the client and server using your package manager they'll be in sync. – Rup May 16 '18 at 16:28
  • @Rup - but the question is whether the other is actually running. – Rick James May 16 '18 at 16:34