1. 程式人生 > 實用技巧 >Jeesite4 初始化資料庫不成功 init datasource error:jdbc...

Jeesite4 初始化資料庫不成功 init datasource error:jdbc...

環境:mysql執行在阿里雲ECS的dokcer裡面

1. docker ps -a 發現mysql執行正常

[root@hadoop101 ~]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                              NAMES
6976d0ac32a3        busybox               "/bin/sh -c 'while t…
" 3 hours ago Up 3 hours test1 b659c3796579 jenkins/jenkins:lts "/sbin/tini -- /usr/…" 11 hours ago Up 11 hours 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp jenkins 7469fe858eee mysql:latest "docker-entrypoint.s…
" 22 hours ago Up 22 hours 0.0.0.0:3306->3306/tcp, 33060/tcp

進入mysql檢視是否存在資料庫jeesite

2. docker exec -it mysql bash

  mysql -u root -p

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jeesite            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5
rows in set (0.00 sec)

3. netstat -tlnp #發現3306埠也開著

[root@hadoop101 ~]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7211/sshd           
tcp6       0      0 :::3306                 :::*                    LISTEN      12954/docker-proxy  
tcp6       0      0 :::8080                 :::*                    LISTEN      15618/docker-proxy  
tcp6       0      0 :::50000                :::*                    LISTEN      15607/docker-proxy  
[root@hadoop101 ~]# docker exec -it mysql bash

4. Navicat for mysql也能連線成功

5. 執行init-data.sh報錯如下:

  init datasource error:jdbc....

6. 到處都是正常的,最後發現是阿里雲安全組裡面的3306埠沒有配,配完了再執行就成功了