====== MySQL: Root-Passwort zurücksetzen ====== Quelle((https://www.linuxmaker.com/tutorials/mysql-rootpasswor.html)) Ab und zu kann es passieren, dass man sein Root-Passwort für den MySQL-Root vergessen hat. Um einer Neuinstallation von MySQLvorzubeugen, möchte ich hier Lösungswege zeigen, mit denen man sich wieder Zutritt zu MySQL verschaffen kann. Grundsätzlich kann man das Rootpasswort so setzen - Öffnen Sie auf dem Server eine Root-Konsole. - Geben Sie folgenden Befehl ein: mysqladmin --user=root --password= password Wenn man aber nicht mehr als Root reinkommt helfen diese zwei Wege. -> Siehe quelle!! Im Falle, dass Sie Ihr MySQL-Passwort vergessen haben, können Sie folgende Kurzanleitung verwenden, um die Root-Rechte zurück zu erlangen.\\ Die Anleitung sollte auf allen gängigen Plattformen funktionieren - Sie müssen jedoch zwingend Zugriff auf die Kommandozeile des Systems haben!\\ Stoppen Sie den mysqld-Demon und starten Sie ihn auf der Kommandozeile mit der Option --skip-grant-tables.\\ Stellen Sie eine Verbindung zum mysqld-Server her, indem Sie folgenden Befehl eingeben: shell> mysql -u root Geben Sie die folgenden Statements im MySQL-Client ein (ersetzen Sie dabei "IhrNeues Passwort" mit dem von Ihnen gewählten Passwort!): mysql> UPDATE mysql.user SET Password=PASSWORD('IhrNeuesPasswort') -> WHERE User='root'; mysql> FLUSH PRIVILEGES; Verlassen Sie den MySQL-Client und restarten Sie Ihren MySQL-Server. Ab jetzt sollten Sie Ihr neues Passwort verwenden können. ====== Can't start/stop mysql service ====== Quelle((http://serverfault.com/questions/32692/cant-start-stop-mysql-service)) ===== Why this is happening ===== This is a common problem if you do a mysql import and overwrite the mysql database itself, such as when you might be restoring from a mysqldump -A backup. This is a good thing: you probably want to back up all your mysql users, permissions, etc -- but it can wreak havoc with things like the debian-sys-maint user used to cleanly shutdown mysql. Although this new database will possibly change both the root password and the debian-sys-maint password, of course it won't automatically change the expected debian-sys-maint password in /etc/mysql/debian.cnf. In fact, unless you also backed up that file, you probably don't even know what that password is anymore! ===== Resetting the mysql root password (optional) ===== First things first. If the mysql root password was different between old and new servers, you can use mysqladmin to fix it: mysql -p -u root password 'newpassword' However, when you apt-get installed mysql-server, it probably prompted you for the new mysql root password and you probably used the same one that you were using from before. ===== Fix the debian sys maint password. ===== So now look up the debian sys maint password that debian created for you when you installed it on the new server. (You need sudo because this should be a highly protected file.) sudo cat /etc/mysql/debian.cnf Now, log in to mysql using the root password you set above: mysql -p -u root # use your new password when prompted Reset the password for the debian-sys-maint user and don't forget to flush privileges: > SET PASSWORD FOR 'debian-sys-maint'@'localhost' = PASSWORD('password_from_/etc/mysql/debian.cnf'); > FLUSH PRIVILEGES; > QUIT Test to be sure it works: sudo /etc/init.d/mysql restart