在CentOS6.x中修改root密碼的幾種情況如下:
1、記得當前root密碼,需要更新密碼,輸入當前密碼,進入mysql
# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3223 Server version: 5.7.13-log MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
mysql> use mysql; mysql> update user set password=PASSWORD('XXXXX@2018~') where user='root'; mysql> flush privileges;
2、忘記root密碼,需要強制修改
# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables & # mysql mysql> use mysql; mysql> update user set password=password("XXXXX@2018~") where user="root"; mysql> flush privileges;
3、5.7.9 修改密碼方法
mysql> update mysql.user set authentication_string=password('XXXXX@2018~') where user='root'; mysql> flush privileges;
