11 March 2020

nak reset root password mysql

1- tutup mysql
$ sudo service mysql stop


2- create run dir for mysqld
$ sudo mkdir -p /var/run/mysqld
$ sudo chown mysql:mysql /var/run/mysqld


3- start mysqld dengan --skip-grant-tables
$ sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
$ [1] 2708

4- connect mysql
$ mysql -u root

5- Flush privileges
mysql> FLUSH PRIVILEGES;

6- set new password
mysql> USE mysql; 
Database changed
mysql> UPDATE user SET authentication_string=PASSWORD("linuxconfig.org") WHERE User='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 1

mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0


7- quit


8- kill mysqld
$ sudo pkill mysqld     


9- restart normal mysql




ref: https://linuxconfig.org/how-to-reset-root-mysql-password-on-ubuntu-18-04-bionic-beaver-linux

No comments:

Post a Comment

Terima kasih