
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;
💘 相关文章
- Implementation method of regular backup of MySQL database
- Tetua-Open source lightweight cms program configuration github login tutorial based on golang and mysql
- docker容器下的MySQL远程连接配置方法
- Docker command all
- MySQL在Mac系統通過brew安裝以及重啟的方法
- MySQL database storage path change
- docker重啟容器的多種方法
- -bash: docker-compose: command not found的两种解决方法
- 收藏:MySQL 數值型函數大全
- 抛弃phpmyadmin吧,一款非常强大的MySQL GUI客户端-HeidiSQL