title: ERROR 1007 (HY000) at line 1: Can't create database 'mgsv'; database exists
body: <p>I converted this <a href="https://github.com/qunfengdong/mGSV/" rel="nofollow noreferrer">original</a> project into a docker-compose project <a href="https://github.com/mictadlo/mGSV-docker" rel="nofollow noreferrer">here</a> and followed a their setup <a href="https://github.com/qunfengdong/mGSV/blob/master/INSTALLATION" rel="nofollow noreferrer">instructions</a>. It seems that I am not able to connect with the browser.</p>
  
  <p>The <a href="https://github.com/mictadlo/mGSV-docker/blob/master/mysql/mgsv.sql" rel="nofollow noreferrer">SQL file</a> contains the database schema and looks like this:</p>
  
  <pre><code>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 ;
  </code></pre>
  
  <p>The <a href="https://github.com/mictadlo/mGSV-docker/blob/master/docker-compose.yml" rel="nofollow noreferrer">docker-compose.yml</a> looks like this:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And the <a href="https://github.com/mictadlo/mGSV-docker/blob/master/mGSV/Dockerfile" rel="nofollow noreferrer">Dockerfile</a> contains PHP and all other tools setup and looks like this.</p>
  
  <pre><code>FROM php:5-apache
  
  RUN apt-get update  &amp;&amp; apt-get install -y --no-install-recommends \
                  openjdk-7-jdk \
                  maven  \
          git \
          &amp;&amp; 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 \
      &amp;&amp; mkdir tmp \
      &amp;&amp; chmod -R 777 tmp
  
  RUN cd /var/www/html/mGSV &amp;&amp; sed -i.bak "s|'gsv'|'mgsv_user'|" lib/settings.php \ 
      &amp;&amp; sed -i.bak "s|$database_pass = ''|$database_pass = 'mgsvpass'|" lib/settings.php \
      &amp;&amp; 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&gt; 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://&lt;YOUR_SERVER_DOMAIN_NAME&gt;/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 \
      &amp;&amp; tar -xzf mgsv-ws-server.tar.gz
  
  RUN cd /var/www/html/mGSV/ws/mgsv-ws-server \ 
      &amp;&amp; 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 \ 
      &amp;&amp; echo "mgsv_upload_url=http://localhost/mgsv" &gt; config.properties \
      &amp;&amp; echo "ws_publish_url=http\://localhost\:8081/MGSVService" &gt;&gt; config.properties \
      &amp;&amp; java -jar ws-server-1.0RC1-jar-with-dependencies.jar &amp;
  
  #To stop the web service
  #shell&gt; ps aux | grep ws-server-1.0RC1-jar-with-dependencies.jar
  #*Note the process id from the output*
  #shell&gt; kill -9 &lt;process id&gt;
  </code></pre>
  
  <p>This is the output which I got:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I am not quite sure whether I did a mistake in the <a href="https://github.com/mictadlo/mGSV-docker/blob/master/docker-compose.yml" rel="nofollow noreferrer">docker-compose.yml</a> file or database configuration inside the <a href="https://github.com/mictadlo/mGSV-docker/blob/master/mGSV/Dockerfile#L16-L18" rel="nofollow noreferrer">Dockerfile</a>.</p>
  
  <p>By any chance, do anyone know what I am missing?</p>
  
  <p>Thank you in advance </p>