how to change mysql server password code example

Example 1: mysql change user password

ALTER USER 'user-name'@'localhost' IDENTIFIED BY 'NEW_USER_PASSWORD';FLUSH PRIVILEGES;

Example 2: mysql change user password

SET PASSWORD FOR 'user-name'@'localhost' = PASSWORD('NEW_USER_PASSWORD');FLUSH PRIVILEGES;

Example 3: mysql set root password

use mysql;

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

flush privileges;

quit

Example 4: what is default mysql database password in linux

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