Accidently locked myself out of MySQL by changing the host
Solution 1:
Stop MySQL:
service mysqld stop
then start MySQL like this
mysqld_safe --skip-grant-tables --skip-networking
At this point you should be able to connect to mysql (from the local machine) as root.
Solution 2:
Ultimately, that option wil be passed to mysqld_safe
; the documentation describes this in detail. You may be able to discover how upstart is invoking MySQL, and then start it manually in similar way with your added --init-file
option. Make sure you start it up as the right user, however!
If you're using Debian or Ubuntu, you will probably find that there is a root-equivalent debian-sys-maint
user which you may be able to use temporarily; you'll find the automatically generated password for that in /etc/mysql/debian.cnf
. There may be alternatives on other systems, too? This option would probably be easier,