当前位置:网站首页>Docker modifies the user name and password of MySQL
Docker modifies the user name and password of MySQL
2022-06-28 10:56:00 【Zhilan was born in a deep valley】
Docker modify Mysql Username and password
1、 Look at the container
[[email protected] ~]# docker ps -a

2、 Get into Mysql Containers
# Look at the picture above to find MySQL Container of id:801f2a6c6c94
[[email protected] ~]# docker exec -it 801f2a6c6c94 /bin/bash
3、 Get into etc/mysql file
[email protected]:/# cd etc/mysql
[email protected]:/etc/mysql# ls
conf.d my.cnf my.cnf.fallback mysql.cnf mysql.conf.d
4、 modify mysql The configuration file

Don't panic at this point , No, vim Then we'll give him a
# to update
apt-get update
# Import
apt-get install

This problem occurs when you import , Do not let import , Then let's update , Import after updating
[email protected]:/etc/mysql# apt-get update

Then you can import vim 了
[email protected]:/etc/mysql# apt-get install vim

Import vim Then modify the configuration file
[email protected]:/etc/mysql# vim my.cnf

[mysqld]
skip-host-cache
skip-name-resolve
skip-grant-tables Skip authority authentication
Save and exit
[email protected]:/# exit
restart mysql Containers
Look at the container first
[[email protected] ~]# docker ps -a

Restart container
[[email protected] ~]# docker restart mysql57
Get into mysql Containers , Connect mysql
[[email protected] ~]# docker exec -it mysql57 /bin/bash
# Here, reset the user name and password
[email protected]:/# mysql -uroot -p
Enter password:

Change Password
mysql> use mysql;
mysql> update user set authentication_string=password(' password ') where user='root';

Delete the line of authority authentication

skip-grant-tables Skip authority authentication This paragraph needs to be deleted , Otherwise, the subsequent login will be password free
[mysqld]
skip-host-cache
skip-name-resolve
skip-grant-tables Skip authority authentication
Refresh the permissions
mysql> flush privileges;

Test connection database
边栏推荐
猜你喜欢
随机推荐
移动命令
Secretary of the Ukrainian national security and National Defense Commission: will carry out precision strikes against targets in Russia
物联网5种无线传输协议特点大汇总
一种跳板机的实现思路
JS基础4
datetime与logging模块
AQS理解
Mongo database
MytipartFile与File的相互转换
How does ETF position affect spot gold price?
Yann LeCun新论文:构建自动智能体之路
JS foundation 4
【功能建议】多个工作空间启动时选择某个空间
工控安全之勒索病毒篇
【LeetCode每日一题】【2021/12/19】997. 找到小镇的法官
毕业季,给初入社会的你一些建议
Yann Lecun's new paper: the road to building automatic agents
flink1.15,支持mysql视图吗?我这边在table-name处配置视图名保存,找不到表。想
港伦敦金行情走势图所隐藏的信息
metersphere使用js刷新当前页面








