docker下部署
文件在容器中路径/etc/mysql/conf.d/docker.cnf
默认配置为:
[mysqld]
skip-host-cache
skip-name-resolve
添加配置skip-grant-tables后:
[mysqld]
skip-host-cache
skip-name-resolve
skip-grant-tables
挂载配置文件到容器内,容器内登陆mysqlmysql -uroot -p回车(安全模式)免密登陆。
mysql> use mysql;
update user set authentication_string='' where user="root";
如果需要给root用户设置密码
update user set plugin='mysql_native_password' where user='root'; #更改加密方式
alter user 'root'@'%' identified by '123456';
FLUSH PRIVILEGES;
注释:%表示授权所有主机登陆,123456为修改后密码。注意,密码太简单是修改会失败,建议设置强密码。
如果无论如何都要使用弱密码,请先执行:
修改validate_password_policy参数的值
set global validate_password_policy=0;
validate_password_length(密码长度)参数默认为8,修改为需要长度
set global validate_password_length=1;
在docker中重启mysql数据库
docker restart ae235c4ae537
参考
https://blog.csdn.net/weixin_46134332/article/details/126396893
https://blog.csdn.net/weixin_44692256/article/details/108239586
普通的部署情况:
寻找my.cnf
linux系统:用ssh登陆服务器后执行mysql --help |grep my.cnf 回车
[root@west9853 etc]# mysql --help |grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /www/wdlinux/etc/my.cnf ~/.my.cnf
配置文件中该行下加入
[mysqld]
skip-grant-tables
然后重启 service mysqld restart
发表评论