配置使用密码方式登录(错误号码:1698-解决方案)
在安装过程中可能没有提示密码设置的环节此时默认使用的是 auth_socket 方式登录,我们需要修改为 mysql_native_password 方式,操作步骤如下:
mysql在哪里:whereis mysql
- 本地登录 MySQL,此时无需输入密码
mysql -u root -p
- 切换数据库到 mysql
use mysql;
- 修改 root 账号密码
update user set authentication_string=password('123456') where user='root';
- 设置登录模式
update user set plugin="mysql_native_password";
- 刷新配置
flush privileges;
- 退出 MySQL
exit;
- 重新启动 MySQL
systemctl restart mysql
配置远程访问(错误号码:2003-解决方案)
- 修改配置文件
vi /etc/mysql/mysql.conf.d/mysqld.cnf
- 注释掉(语句前面加上
#
即可):
# bind-address = 127.0.0.1
- 重启 MySQL
service mysql restart
- 登录 MySQL
mysql -u root -p
- 授权 root 用户允许所有人连接
grant all privileges on *.* to 'root'@'%' identified by 'Your Password';
因弱口令无法成功授权解决步骤
- 查看和设置密码安全级别
select @@validate_password_policy;set global validate_password_policy=0;
- 查看和设置密码长度限制
select @@validate_password_length;set global validate_password_length=1;
其它配置
修改配置文件:vi /etc/mysql/mysql.conf.d/mysqld.cnf
[client]default-character-set=utf8[mysqld]default-storage-engine=INNODBcharacter-set-server=utf8collation-server=utf8_general_cilower-case-table-names=1
注意: 配置内容追加到对应节点的底部即可