
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;
💘 相关文章
- docker容器下的MySQL远程连接配置方法
- Tetua-Open source lightweight cms program configuration github login tutorial based on golang and mysql
- Implementation method of regular backup of MySQL database
- MySQL在Mac系統通過brew安裝以及重啟的方法
- 又一款基于golang,MySQL的开源论坛程序。。。
- mysql定時去重的方法
- Mac 系统docker 设置国内镜像加速的方法
- debian安装docker和Docker面板Portainer并部署Wordpress
- Debian 10 installation MySQL server record
- 轻量级的Php mysql web 管理客户端程序Adminer