
MySQL remote connection configuration method under docker container
MySQL remote connection configuration method under docker container
View the processes running by docker
docker ps -a
Show as below
1
2
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES784d7bfaba29 centos_ssl:v1 "/bin/bash" 26 hours ago Created centos_ssl
b26848309b77 centos:v4 "/bin/bash" 26 hours ago Up About an hour
As can be seen from the information above, the docker container is running a centos system. . .
We enter the centos system of this docker container
docker exec -it b26848309b77 bash
Note that because it is a docker container running the Centos system,
If you are directly running the MySQL server, you can execute the following command to enter MySQL
docker exec -it mysql bash
mysql is an alias, you can also use docker container id to enter inside. . .
For example, the above docker exec -it b26848309b77 bash
b26848309b77 is the id running in the docker container. . .
Next, you can configure MySQL remote connectionAs can be seen from the information above, the docker container is running a centos system. . .
We enter the centos system of this docker container
docker exec -it b26848309b77 bash
Note that because it is a docker container running the Centos system,
If you are directly running the MySQL server, you can execute the following command to enter MySQL
docker exec -it mysql bash
mysql is an alias, you can also use docker container id to enter inside. . .
For example, the above docker exec -it b26848309b77 bash
b26848309b77 is the id running in the docker container. . .
Next, you can configure MySQL remote connection
1
2
3
4
5
6
mysql -uroot -p //login mysql server
use mysql; // use mysql data
select host,user,plugin,authentication_string from mysql.user; //view user info
update user set host='192.168.1.%' where user ='root';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%'WITH GRANT OPTION;
Only run the IP segment from 192.168.1.x
to connect to the MySQL server
Allow connection to MySQL server from any network, modify to the following code
1
2
3
update user set host='%' where user ='root';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
In order to facilitate the use of local programs, we also need to add local MySQL connection permissions
1
2
3
CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'yourpasswd';
GRANT EXECUTE, PROCESS, SELECT, SHOW DATABASES, SHOW VIEW, ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TABLESPACE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, INDEX, INSERT, REFERENCES, TRIGGER, UPDATE, CREATE USER, FILE, LOCK TABLES, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SHUTDOWN, SUPER ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;
💘 相关文章
- Tetua-Open source lightweight cms program configuration github login tutorial based on golang and mysql
- Implementation method of regular backup of MySQL database
- docker容器下的MySQL远程连接配置方法
- Tetua - an open source lightweight cms program based on golang and mysql, with installation and configuration
- Tetua-基于golang和mysql的开源轻量级cms程序配置github登录教程
- ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?解决方法
- Tetua-基于golang和mysql的开源轻量级cms程序,附上安装和配置教程
- chevereto 50%优惠限时促销
- 一键安装docker的方法,只需两条命令
- debian安装docker和Docker面板Portainer并部署Wordpress