gpt4 book ai didi

java - 第 1 行 : Can't create database 'mgsv' ; database exists 处出现错误 1007 (HY000)

转载 作者:行者123 更新时间:2023-11-29 06:46:03 26 4
gpt4 key购买 nike

我转换了这个original项目到 docker-compose 项目 here并遵循他们的设置instructions 。我似乎无法连接浏览器。

SQL file包含数据库架构,如下所示:

CREATE DATABASE mgsv;
CREATE USER 'mgsv_user'@'localhost' IDENTIFIED BY 'mgsvpass';
GRANT SELECT, INSERT, CREATE, DROP ON mgsv.* TO 'mgsvuser'@'localhost';
use mgsv;
CREATE TABLE IF NOT EXISTS `userinfo` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`email` text NOT NULL,
`hash` text NOT NULL,
`synfilename` text NOT NULL,
`annfilename` text NOT NULL,
`url` text NOT NULL,
`session_id` text NOT NULL,
`annImage` int(5) NOT NULL,
`create_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

docker-compose.yml看起来像这样:

version: '3.1'

services:
db:
image: mysql
restart: always
environment:
- MYSQL_DATABASE=mgsv
- MYSQL_USER=mgsv_user
- MYSQL_PASSWORD=mgsvpass
- MYSQL_ROOT_PASSWORD=mysql123
volumes:
- ./mysql:/docker-entrypoint-initdb.d

www:
build: ./mGSV
restart: always
ports:
- 8080:8080

还有Dockerfile包含 PHP 和所有其他工具设置,如下所示。

FROM php:5-apache

RUN apt-get update && apt-get install -y --no-install-recommends \
openjdk-7-jdk \
maven \
git \
&& rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/qunfengdong/mGSV.git

# Move the folder 'mgsv' to DocumentRoot of Apache web server. By default, the DocumentRoot of Apache is /var/www/ (speak to the system administrator to know the exact DocumentRoot).
RUN cd /var/www/html/mGSV \
&& mkdir tmp \
&& chmod -R 777 tmp

RUN cd /var/www/html/mGSV && sed -i.bak "s|'gsv'|'mgsv_user'|" lib/settings.php \
&& sed -i.bak "s|$database_pass = ''|$database_pass = 'mgsvpass'|" lib/settings.php \
&& sed -i.bak "s|cas-qshare.cas.unt.edu|localhost|" lib/settings.php

RUN cp /var/www/html/mGSV/Arial.ttf /usr/share/fonts/truetype/

#Do not understand
#7. Cleanup scripts are provided to drop database synteny and annotation tables, remove entries from database table 'userinfo' and delete the folder containing image files which are older than 60 days. This task is accomplished by cron job to run the cleanup script every day. To create a cron job, use the command below:
# shell> crontab -e

#At the last line of crontab, copy and paste the line below, and provide the exact path to mgsv/lib/cleanup.php
# 30 04 * * * /var/www/mgsv/lib/cleanup.php

#The script cleanup.php will be executed at 4:30 AM every morning.

#8. mGSV uses the mail function from PHP to send email to users. Speak to your system administrator to provide required information in the PHP configuration file called 'php.ini'.

#9. When installation completes, you can now open Install/index.php (i.e., http://<YOUR_SERVER_DOMAIN_NAME>/mgsv/Install/), which verifies prerequisites, database setup, and installation. YOUR_SERVER_DOMAIN_NAME refers to the domain name of your server.


RUN cd /var/www/html/mGSV/ws \
&& tar -xzf mgsv-ws-server.tar.gz

RUN cd /var/www/html/mGSV/ws/mgsv-ws-server \
&& mvn package

RUN cp -f /var/www/html/mGSV/ws/mgsv-ws-server/target/ws-server-1.0RC1-jar-with-dependencies.jar /var/www/html/mGSV/ws/

RUN cd /var/www/html/mGSV/ws \
&& echo "mgsv_upload_url=http://localhost/mgsv" > config.properties \
&& echo "ws_publish_url=http\://localhost\:8081/MGSVService" >> config.properties \
&& java -jar ws-server-1.0RC1-jar-with-dependencies.jar &

#To stop the web service
#shell> ps aux | grep ws-server-1.0RC1-jar-with-dependencies.jar
#*Note the process id from the output*
#shell> kill -9 <process id>

这是我得到的输出:

Attaching to mgsvdocker_www_1, mgsvdocker_db_1
www_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.2. Set the 'ServerName' directive globally to suppress this message
www_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.2. Set the 'ServerName' directive globally to suppress this message
www_1 | [Mon Mar 19 22:12:02.742360 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/5.6.34 configured -- resuming normal operations
www_1 | [Mon Mar 19 22:12:02.744224 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
db_1 | Initializing database
db_1 | 2018-03-19T22:12:02.855291Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1 | 2018-03-19T22:12:03.251862Z 0 [Warning] InnoDB: New log files created, LSN=45790
db_1 | 2018-03-19T22:12:03.348644Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
db_1 | 2018-03-19T22:12:03.411853Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 8d99d2f8-2bc2-11e8-8ace-0242ac140003.
db_1 | 2018-03-19T22:12:03.414590Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db_1 | 2018-03-19T22:12:03.415526Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
db_1 | 2018-03-19T22:12:05.555076Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.555603Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.556433Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.557353Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.558712Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.559068Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.559557Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:05.560388Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | Database initialized
db_1 | Initializing certificates
db_1 | Generating a 2048 bit RSA private key
db_1 | ..........................................+++
db_1 | ...........................+++
db_1 | unable to write 'random state'
db_1 | writing new private key to 'ca-key.pem'
db_1 | -----
db_1 | Generating a 2048 bit RSA private key
db_1 | ....................................................................+++
db_1 | .................................................+++
db_1 | unable to write 'random state'
db_1 | writing new private key to 'server-key.pem'
db_1 | -----
db_1 | Generating a 2048 bit RSA private key
db_1 | ..........+++
db_1 | ...................................+++
db_1 | unable to write 'random state'
db_1 | writing new private key to 'client-key.pem'
db_1 | -----
db_1 | Certificates initialized
db_1 | MySQL init process in progress...
db_1 | 2018-03-19T22:12:09.627477Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1 | 2018-03-19T22:12:09.628759Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 87 ...
db_1 | 2018-03-19T22:12:09.633134Z 0 [Note] InnoDB: PUNCH HOLE support available
db_1 | 2018-03-19T22:12:09.634171Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1 | 2018-03-19T22:12:09.634378Z 0 [Note] InnoDB: Uses event mutexes
db_1 | 2018-03-19T22:12:09.634769Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db_1 | 2018-03-19T22:12:09.635298Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
db_1 | 2018-03-19T22:12:09.635485Z 0 [Note] InnoDB: Using Linux native AIO
db_1 | 2018-03-19T22:12:09.636263Z 0 [Note] InnoDB: Number of pools: 1
db_1 | 2018-03-19T22:12:09.636914Z 0 [Note] InnoDB: Using CPU crc32 instructions
db_1 | 2018-03-19T22:12:09.639991Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db_1 | 2018-03-19T22:12:09.650561Z 0 [Note] InnoDB: Completed initialization of buffer pool
db_1 | 2018-03-19T22:12:09.660208Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1 | 2018-03-19T22:12:09.673096Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db_1 | 2018-03-19T22:12:09.697190Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1 | 2018-03-19T22:12:09.701919Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1 | 2018-03-19T22:12:09.754718Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1 | 2018-03-19T22:12:09.756113Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db_1 | 2018-03-19T22:12:09.756140Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db_1 | 2018-03-19T22:12:09.757786Z 0 [Note] InnoDB: Waiting for purge to start
db_1 | 2018-03-19T22:12:09.808245Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 2551166
db_1 | 2018-03-19T22:12:09.809069Z 0 [Note] Plugin 'FEDERATED' is disabled.
db_1 | 2018-03-19T22:12:09.817123Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1 | 2018-03-19T22:12:09.822791Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180319 22:12:09
db_1 | 2018-03-19T22:12:09.834211Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db_1 | 2018-03-19T22:12:09.834819Z 0 [Warning] CA certificate ca.pem is self signed.
db_1 | 2018-03-19T22:12:09.846515Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.846560Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.846579Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.846613Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.846622Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.846640Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.853203Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.853233Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:09.890674Z 0 [Note] Event Scheduler: Loaded 0 events
db_1 | 2018-03-19T22:12:09.890927Z 0 [Note] mysqld: ready for connections.
db_1 | Version: '5.7.21' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
db_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
db_1 | 2018-03-19T22:12:13.111650Z 4 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.113784Z 4 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.115619Z 4 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.118409Z 4 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.118432Z 4 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.118458Z 4 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.118526Z 4 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.118543Z 4 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | 2018-03-19T22:12:13.219113Z 8 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222332Z 8 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222366Z 8 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222426Z 8 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222437Z 8 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222459Z 8 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222753Z 8 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-03-19T22:12:13.222768Z 8 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1 |
db_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/mgsv.sql
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | ERROR 1007 (HY000) at line 1: Can't create database 'mgsv'; database exists

我不太确定我是否在 docker-compose.yml 中犯了错误Dockerfile 内的文件或数据库配置.

有谁知道我错过了什么吗?

提前谢谢

最佳答案

您在 docker-compose.yml 文件中为 mysql 容器设置了环境变量“MYSQL_DATABASE=mgsv”。当mysql容器创建并启动时,它会自动创建数据库mgsv,并允许用户mgsv_user(由环境变量“MYSQL_USER=mgsv_user指定) >") 来访问它。详情可查看official documentation对于 mysql 镜像。

您应该做的是,从 SQL 文件中删除语句“CREATE DATABASE mgsv;”,或将该语句更改为“CREATE DATABASE IF NOT EXISTS mgsv;” >”。您可能还需要调整该 SQL 文件中的其他语句(例如,在本例中不需要创建用户)。

关于java - 第 1 行 : Can't create database 'mgsv' ; database exists 处出现错误 1007 (HY000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49373422/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com