Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 主机';172.23.0.9';不允许连接到此服务器_Java_Spring_Docker - Fatal编程技术网

Java 主机';172.23.0.9';不允许连接到此服务器

Java 主机';172.23.0.9';不允许连接到此服务器,java,spring,docker,Java,Spring,Docker,你好 弹簧设置 spring.jpa.hibernate.ddl-auto=update spring.datasource.url= jdbc:mysql://vetdb:3306/vetdb?useSSL=false&allowPublicKeyRetrieval=true spring.datasource.username=root spring.datasource.testWhileIdle = true spring.datasource.validationQuery

你好

弹簧设置

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url= jdbc:mysql://vetdb:3306/vetdb?useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root  
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.platform=mysql

spring.datasource.initialize=true
spring.jpa.show-sql=false

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

spring.jmx.default-domain=TierarztDatenController
endpoints.jmx.uniquie-names=true
Docker Compose

  vetdb:
    container_name: vetdb
    hostname: vetdb
    image: mariadb
    restart: always
    command: --default-authentication-plugin=mysql_native_password --innodb-flush-method=O_DSYNC --innodb-use-native-aio=0 --log_bin=ON
    environment:
      MYSQL_ROOT_PASSWORD: ${VET_DB_ROOT_PASSWORD}
      MYSQL_DATABASE: ${VET_DB_NAME}
      MYSQL_PASSWORD: ${VET_DB_PASSWORD}
      MYSQL_ROOT_HOST: '%'
    volumes:
#      - "${VET_DB_PATH}/mysql-conf:/etc/mysql/conf.d"
      - "${VET_DB_PATH}:/var/lib/mysql"
      - "${VET_DB_PATH}/mysql-log:/var/log/mysql"
环境署署长

我添加了
MYSQL\u ROOT\u主机:“”
以允许每个人都连接到数据库,但它不起作用 我试图使用一个包含
绑定地址=0.0.0.0
配置文件.cnf
,但它不起作用

有趣的是,在我今天重新启动容器之前,一切都很好,我在三天内没有更改此服务

我尝试查看name/password是否为root工作

$ docker exec -it vetdb bash
root@vetdb:/# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
但是没有密码的root可以工作(在容器内)

如果我只是删除
spring.datasource.password=root
或者将其设置为
spring.datasource.password=
然后它会导致相同的异常


我做错了什么?

我将环境变量更改为

环境:
-“MYSQL_ROOT_PASSWORD=${VET_DB_ROOT_PASSWORD}”
-“MYSQL_数据库=${VET_DB_NAME}”

-“MYSQL\u ROOT\u HOST=%”
似乎MYSQL忽略了我设置的所有环境变量,因为我指定的数据库也不存在
$ docker exec -it vetdb bash
root@vetdb:/# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@vetdb:/# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 21
Server version: 10.3.9-MariaDB-1:10.3.9+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>