reset root password in mysql code example

Example 1: set password mysql

-- In case the UPDATE command returns "Column 'Password' is not updatable" run
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPassword';
flush privileges;

Example 2: mysql set root password

use mysql;

update user set authentication_string=PASSWORD("mynewpassword") where User='root';

flush privileges;

quit

Example 3: alter user root mysql

ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPassword';

Example 4: what is default mysql database password in linux

$ sudo apt install mysql-server
$ sudo cat /etc/mysql/debian.cnf

Tags:

Sql Example