1.下载好mysql后,打开终端
➜ tmp mysql -u root -p Enter password:
2.直接回车,进入mysql控制台,设置新密码
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你的新密码');
3.退出重进,直接回车不输入密码,提示密码错误
➜ tmp mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
4.输入刚刚设定的密码,成功进入
➜ tmp mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 12 Server version: 5.7.27 Homebrew Copyright (c) 2000, 2019, 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> show databases -> ; +------------------------------+ | Database | +------------------------------+ | information_schema | | commerce_backend_development | | commerce_backend_production | | commerce_backend_test | | mysql | | performance_schema | | sys | +------------------------------+ 7 rows in set (0.01 sec)