DevHeads.net

How to start and stop mysql?

I need to start and stop mysql, and I've only figured out how to stop it.
I need to start it (not rebooting) so that I can temporarily use different
options. In my case, I need --skip-grant-tables.

Comments

Re: How to start and stop mysql?

By Wade Smart at 01/12/2018 - 11:08

sudo service mysql start

Re: How to start and stop mysql?

By Volker Wysk at 01/12/2018 - 11:22

Am Freitag, 12. Januar 2018, 09:08:22 CET schrieb Wade Smart:
This just starts mysql the normal way. But the OP said, that he needs to start it temporarily with self specified options.

The following is how mysql is normally started (this is taken from /etc/init.d/mysql):

# Start MySQL!
su - mysql -s /bin/sh -c "/usr/bin/mysqld_safe > /dev/null 2>&1 &"

So the OP could use this, modify it as needed.

Cheers
Volker

Re: How to start and stop mysql?

By Volker Wysk at 01/12/2018 - 13:09

Am Freitag, 12. Januar 2018, 08:46:21 CET schrieb Kevin O'Gorman:
Good luck

Volker

Re: How to start and stop mysql?

By Kevin O'Gorman at 01/12/2018 - 14:27

And mysql itself reports
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)

But 'service mysql start' works okay. I'll have to figure out how it does
that. Or just temporarily edit mysqld_safe.

Re: How to start and stop mysql?

By Kevin O'Gorman at 01/12/2018 - 20:24

In particular mysqld.cnf in that directory looks sort of like a script, but
is turned into command-line parameters.
I added mine there, and was able to turn off passwords for a bit, and do
the cleanup by following instructions
in <a href="https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html" title="https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html">https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html</a>

Now I have a working root password again.

Re: How to start and stop mysql?

By Colin Law at 01/12/2018 - 12:55

I believe you should be able to pass the option to mysqld_safe and it will
be passed to mysqld
<a href="https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html" title="https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html">https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html</a>

Colin