全步骤解析

 

拉取镜像就不说了,可以去看博客。

https://blog.csdn.net/qq_33792843/article/details/82849169

 

进入docker之后,mysql密码肯定是有问题的。我们需要改密码。

1.vi /etc/my.cnf

在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程

docker起mysql服务

保存文档并退出:

:wq!

 

2.重启服务

service mysqld restart

 

3.进入mysql

mysql -uroot -p

 

4.接下来就是用sql来修改root的密码

mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit

到这里root账户就已经重置成新的密码了。

update user set password=password("123456") where user="root";

 

 

5.将免**功能去除。

编辑my.cnf,去掉刚才添加的内容,然后重启MySQL。大功告成!

docker起mysql服务

 

 

特别说明:

如果是新手,可以这么找mysql的my.cfg

whereis my

 

 

 

但是问题来了。容器里的mysql如何通过外面访问呢?

 

mysql库,user表。

 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

FLUSH PRIVILEGES ;

 

 

 

 

 

 

 

 

相关文章:

  • 2021-08-15
  • 2021-04-13
  • 2021-06-26
  • 2022-12-23
  • 2021-11-03
  • 2021-10-25
  • 2021-05-23
猜你喜欢
  • 2022-01-06
  • 2021-12-16
  • 2021-07-27
  • 2021-08-12
  • 2022-12-23
  • 2021-04-09
相关资源
相似解决方案