Questions about connecting to the database in docker-compose

as shown in the figure, this is the docker-compose configuration file
clipboard.png

clipboard.png

dockerredis-climysqlredis mysql

clipboard.png

clipboard.png

webmysql:

clipboard.png

webhostdocker-composeservice

clipboard.png

but it doesn"t help. I still reported the mistake in the picture. I"ve been entangled for a day, asking for help

.

now the latest image of mysql is 8.0. It is recommended to try 5.7.22. In addition, it is recommended to use the network alias direct alias as the connection target host in compose to use the dns maintained in docker's network

.

if you troubleshoot your problems, go to the service name of mysql under ping in the web container to see if ip is returned, or docker run-ti-- rm-- net:container:web container id zhangguanzhang/alpine sh to use the web container with the same network namespace to troubleshoot
and see if telnet mysql 3389 can get through


error message "Client does not support authentication protocol".
look at your configuration. There should be something wrong with your server configuration in node web. Your mysql configuration has root users and passwords. It is recommended that you write all these in your nodejs configuration.

you can also create users and passwords through mysql links. The following example code


docker-compose networks :

version: '3'
services: 
  web:
    networks: -sharp 
      - my-network
      
  mysql:
    networks: -sharp 
      - my-network
          
networks:          
  my-network:      
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bca0a8-309be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bca0a8-309be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?