使用MySQL mysql-5.7.20-macos10.12-x86_64.dmg版本配置默认编码全部改为UTF-8,执行以下命令报错:
$ mysql -u root -p
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
MySQL第一次安装的密码会系统通知:
再次执行mysql -u root -p 输入正确密码:
检查编码,使用默认密码需要重新更改密码,这里暂时为了方便设置为空(生产环境会被打死吧!!!):
mysql> show variables like '%char%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password for 'root'@'localhost' =password('');
mysql> exit
增加编码配置文件:
$ cd /private/etc/
$ sudo vim my.cnf
重启mysql,数据库默认的编码全部改为UTF-8: