How To Reset MySQL Or MariaDB Root Password

Aus Thoms Wiki
Version vom 12. April 2019, 20:21 Uhr von all>Verkehrsminister
Zur Navigation springenZur Suche springen

taken from https://www.ostechnix.com/how-to-reset-mysql-or-mariadb-root-password/

DB stoppen

systemctl stop mysql
  oder
systemctl stop mariadb
  oder auch
/etc/init.d/mysql stop

Next, restart the database server without permission checking using the following command:

mysqld_safe --skip-grant-tables &

Login

mysql

At the mysql> or MariaDB [(none)]> prompt, run the following command to reset the root user password:

UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;
exit

Finally, shutdown the running database server that you started earlier with --skip-grant-tablesoption. To do so, run:

mysqladmin -u root -p shutdown

DB wieder starten

systemctl start mysql
  oder
systemctl start mariadb

Verify if the password has really been changed using the following command:

mysql -u root -p