我是docker world的新手,它试图通过Spring Boot v2.2.6.RELEASE连接到安装在Docker主机(远程计算机)上的MySQL。
docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test mysql
5ad7a9d9f464f3c026f1668f5507d3bc9eb98069b6a543ad94e6a74c68dfefc7
[user@user]$ docker exec -it mysql bash -l
mysql -uroot -proot
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.01 sec)
它是一个Spring Boot和Batch项目,我错过了任何配置吗?
application.properties
# MYSQL DB Details
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://<docker-host-ip>:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.schema=org/springframework/batch/core/schema-mysql.sql
spring.batch.initialize-schema=ALWAYS