数据库版本:8.0.19
执行
./mysql -u root -p
报错:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
方法:
1.苹果->系统偏好设置->最下面点mysql,关闭mysql服务
2.在终端
cd /usr/local/mysql/bin/
3.管理员权限
sudo su
4.回车以禁止mysql验证功能,mysql会自动重启,偏好设置中的mysql状态会变成running
./mysqld_safe --skip-grant-tables &
5.进入sql
./mysql
注意分号
flush privileges;
注意这是新版sql的语法
set password for 'root'@'localhost' = 'root';
重新登录正常:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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.
https://blog.csdn.net/z90818/article/details/88106973