# ================== 使用mysqladmin ==================
$ mysqladmin -u root -p password '123456';
# ================== 使用空密码直接登录 ==================
$ mysql - u root -p
# 修改方式一
mysql> set password for root@localhost = password('123456');
# 修改方式二
mysql> use mysql;
mysql> update user set password=password('123456') where user='root' and host='localhost';
mysql> flush privileges;
# ================== 忘记密码重置密码 ==================
# 关闭 MySQL 服务
$ service mysql stop
$ mysqld --skip-grant-tables
mysql> use mysql;
mysql> update user set password=password('123456') where user='root' and host='localhost';
mysql> flush privileges;
mysql> quit
# 开启 MySQL 服务
$ service mysql start