方法一

1
2
3
4
MariaDB [mysql]> set password for root@localhost=password('xxoo321');
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

方法二

1
2
3
4
5
MariaDB [mysql]> update user set password=password('ooxx233')where user='root'and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

方法三

1
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456!';