Home  >  Article  >  Computer Tutorials  >  How to solve the problem of slow Mysql connection in Docker

How to solve the problem of slow Mysql connection in Docker

PHPz
PHPzforward
2024-02-19 15:09:51552browse

After using Docker to deploy MySQL, the connection speed is slow. Through online search, I found that the problem may be caused by the lack of DNS resolution and other modules during the minimum container installation.

How to solve the problem of slow Mysql connection in Docker

So there will be a problem of super slow connection when connecting, we directly add this sentence

skip-name-resolve

We directly modify the docker-compose.yml configuration, the configuration is as follows

version: "3"
services:
mysql:
image: mysql:latest
container_name: mysql_compose
restart: always
ports:
- 3306:3306
command: --default-authentication-plugin=mysql_native_password --skip-name-resolve
environment:
- MYSQL_ROOT_PASSWORD=test
volumes:
- /home/data/mysql:/var/lib/mysql

Re-execute, so the speed will be improved.

The above is the detailed content of How to solve the problem of slow Mysql connection in Docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete