1,新装mysql,添加密码
mysqladmin -u root password NEWPASSWORD
2,记得旧密码,改密码
mysqladmin -u root -p'OLDPASSWORD' password NEWPASSWORD
3,不记得旧密码,新设密码
- Stop the MySQL server process with the command: sudo service mysql stop
- Start the MySQL server with the command: sudo mysqld_safe —skip-grant-tables —skip-networking &
- Connect to the MySQL server as the root user with the command: mysql -u root
At this point, you need to issue the following MySQL commands to reset the root password:
mysql> use mysql;
mysql> update user set authentication_string=password('NEWPASSWORD') where user='root';
mysql> flush privileges;
mysql> quit