02 Feb 2016
Mysql und Mariadb: Root-Passwort ändern
Ändern des Root-Passworts des Mysql-Root-Users
Ein Klacks!
- zuerst nachsehen, wieviele Root-User man hat
root@localhost [(none)]> SELECT user,host,password FROM mysql.user WHERE user LIKE "%root%";
+------+-----------+-------------------------------------------+
| User | Host | Password |
+------+-----------+-------------------------------------------+
| root | localhost | *DEDB8835ED....................854F67FD5F |
| root | amberd | *DEDB8835ED....................854F67FD5F |
| root | 127.0.0.1 | *DEDB8835ED....................854F67FD5F |
| root | ::1 | *DEDB8835ED....................854F67FD5F |
+------+-----------+-------------------------------------------+
5 rows in set (0.002 sec)
- Danach für alle das neue Passwort setzen, und die Privilegien spülen
- Anmerkung: SUPERSECURE ist hier nur ein Platzhalter und darf unter keinen Umständen verwendet werden.
root@localhost [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('SUPERSECURE');
Query OK, 0 rows affected (0.091 sec)
root@localhost [(none)]> SET PASSWORD FOR 'root'@'amberd' = PASSWORD('SUPERSECURE');
Query OK, 0 rows affected (0.016 sec)
root@localhost [(none)]> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('SUPERSECURE');
Query OK, 0 rows affected (0.013 sec)
root@localhost [(none)]> SET PASSWORD FOR 'root'@'::1' = PASSWORD('SUPERSECURE');
Query OK, 0 rows affected (0.027 sec)
root@localhost [(none)]> flush privileges;
Query OK, 0 rows affected (0.061 sec)
- Schussendlich kontrollieren, ob es geklappt hat.
root@localhost [(none)]> SELECT user,host,password FROM mysql.user WHERE user LIKE "%root%";
+------+-----------+-------------------------------------------+
| User | Host | Password |
+------+-----------+-------------------------------------------+
| root | localhost | *FA64DBF8....................0EF7F4169507 |
| root | amberd | *FA64DBF8....................0EF7F4169507 |
| root | 127.0.0.1 | *FA64DBF8....................0EF7F4169507 |
| root | ::1 | *FA64DBF8....................0EF7F4169507 |
+------+-----------+-------------------------------------------+