How to stop MySQL after running it using mysqld_safe?
Asked Answered
M

2

21

I'm using mysqld_safe to be able to create a password for my root user (under Ubuntu 18.04, it is not asked on the installation).

To start MySQL, I have done:

$ sudo mysqld_safe --skip-grant-tables&

Now, the MySQL daemon is running and I can't stop it. Stopping it by killing the process prevent me to start another MySQL daemon because the previous one did not gave back the resources, resulting in errors like:

2018-10-31T14:50:40.238735Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2018-10-31T14:50:40.238815Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

So how can I stop the MySQL daemon when it have been started using mysqld_safe?

Mg answered 31/10, 2018 at 15:7 Comment(2)
Stack Overflow is a site for programming and development questions. Maybe Database Administrators Stack Exchange would be a better place to ask.Hinch
#37879948Dilation
M
35

The command is:

$ mysqladmin shutdown
Mg answered 31/10, 2018 at 15:7 Comment(5)
If your goal is to create a user, run mysqld_safe without putting it in the background (&) so you can just ^C break it and go back to regular operation.Pirate
@jackalope I've noticed newer MySQL versions require ^\ (SIGQUIT).Pirate
Running this gave me access deniedLiva
on mac need to include user eg: mysqladmin -u root shutdown otherwise mysqladmin will try to use default user which is your current user.Anthology
I needed sudo mysqladmin shutdownKuroshio
H
7

The other answers did not work for me. Had to to this sudo killall -KILL mysql mysqld_safe mysqld

Henry answered 8/5, 2020 at 21:49 Comment(1)
Never use this if you want to avoid database inconsistencies. Kill signal terminates MySQL instantly and if it has a running transaction that will prematurely end. QUIT signal (as @Pirate wrote) avoids this situation and terminates MySQL properly.Cheesy

© 2022 - 2024 — McMap. All rights reserved.