RedpointArchive / phabricator

A Docker image that runs Phabricator, an open source software engineering tool
https://hub.docker.com/r/redpointgames/phabricator/
307 stars 98 forks source link

cannot connet to root@mysql #78

Closed xiaoxinyi closed 7 years ago

xiaoxinyi commented 7 years ago

I use docker-compose to setup phabricator.

 version: '2'
 services:
     phabricator:
           restart: always
           ports:
             - "62443:443"
             - "62080:80"
             - "62022:22"
           volumes:
             - ./phabricator/repos:/repos
             - ./phabricator/extensions:/srv/phabricator/phabricator/src/extensions
           depends_on:
             - mysql
           links:
             - mysql
           environment:
             - MYSQL_HOST=mysql
             - MYSQL_USER=root
             - MYSQL_PASS=phabricator
             - PHABRICATOR_REPOSITORY_PATH=/repos
             - PHABRICATOR_HOST=192.168.199.208
           image: redpointgames/phabricator
     mysql:
           restart: always
           volumes:
             - ./phabricator/mysql:/var/lib/mysql
           image: mysql:5.7.14
           environment:
             - MYSQL_ROOT_PASSWORD=phabricator

I use docker-compose up to setup the application. Error when connecting mysql

 Raw MySQL Error: Attempt to connect to root@mysql failed with error #2002:

...

mysqlcheck: Got error: 1049: Unknown database 'phabricator_search' when selecting the database
hach-que commented 7 years ago

I'm assuming you waited until the nginx service has started in the container? Can you please paste a copy of the container logs?

hach-que commented 7 years ago

Please paste a full copy of the container logs.

xiaoxinyi commented 7 years ago

docker-compose up logs

hach-que commented 7 years ago

From the logs, it looks like you might be restarting the same container after it has already started once. This container should be run with --rm as it is not restartable.

The other thing is that the container can definitely connect to MySQL, as it does so here:

�[32mzl_phabricator |�[0m phabricator_search.edge                            OK
�[32mzl_phabricator |�[0m phabricator_search.edgedata                        OK
�[32mzl_phabricator |�[0m phabricator_search.search_document                 OK
�[32mzl_phabricator |�[0m phabricator_search.search_documentfield            OK
�[32mzl_phabricator |�[0m phabricator_search.search_documentrelationship     OK
�[32mzl_phabricator |�[0m phabricator_search.search_editengineconfiguration  OK
�[32mzl_phabricator |�[0m phabricator_search.search_editengineconfigurationtransaction OK
�[32mzl_phabricator |�[0m phabricator_search.search_indexversion             OK
�[32mzl_phabricator |�[0m phabricator_search.search_namedquery               OK
�[32mzl_phabricator |�[0m phabricator_search.search_profilepanelconfiguration OK
�[32mzl_phabricator |�[0m phabricator_search.search_profilepanelconfigurationtransaction OK
�[32mzl_phabricator |�[0m phabricator_search.search_savedquery               OK
�[32mzl_phabricator |�[0m phabricator_search.stopwords                       OK
�[32mzl_phabricator |�[0m + /srv/phabricator/phabricator/bin/storage upgrade --force
�[32mzl_phabricator |�[0m Storage is up to date. Use "storage status" for details.
�[32mzl_phabricator |�[0m Synchronizing static tables...
�[32mzl_phabricator |�[0m Verifying database schemata on "mysql"...
�[32mzl_phabricator |�[0m Found no adjustments for schemata.

But then later, the same credentials fail when the boot script runs again (which should never happen, because the container should be deleted before starting again):

�[35mzl_phabricator |�[0m mysqlcheck: Got error: 2003: Can't connect to MySQL server on 'mysql' (111 "Connection refused") when trying to connect
�[35mzl_phabricator |�[0m + /srv/phabricator/phabricator/bin/storage upgrade --force
�[35mzl_phabricator |�[0m MySQL Credentials Not Configured
�[35mzl_phabricator |�[0m 
�[35mzl_phabricator |�[0m Unable to connect to MySQL using the configured credentials. You must
�[35mzl_phabricator |�[0m configure standard credentials before you can upgrade storage. Run these
�[35mzl_phabricator |�[0m commands to set up credentials:
�[35mzl_phabricator |�[0m 
�[35mzl_phabricator |�[0m   phabricator/ $ ./bin/config set mysql.host __host__
�[35mzl_phabricator |�[0m   phabricator/ $ ./bin/config set mysql.user __username__
�[35mzl_phabricator |�[0m   phabricator/ $ ./bin/config set mysql.pass __password__
�[35mzl_phabricator |�[0m 
�[35mzl_phabricator |�[0m These standard credentials are separate from any administrative credentials
�[35mzl_phabricator |�[0m provided to this command with __--user__ or __--password__, and must be
�[35mzl_phabricator |�[0m configured correctly before you can proceed.
�[35mzl_phabricator |�[0m 
�[35mzl_phabricator |�[0m Raw MySQL Error: Attempt to connect to root@mysql failed with error #2002:
�[35mzl_phabricator |�[0m Connection refused.

It's possible that the mysql hostname is no longer pointing at MySQL, which would also cause this issue.

xiaoxinyi commented 7 years ago

@hach-que Thanks. Every time I start the container, I will docker-compose down and remove the files in ./phabricator/mysql. Maybe I should redefine the service name mysql?

hach-que commented 7 years ago

I don't think you need to remove the MySQL container; just the Phabricator container.

tkambler commented 7 years ago

@xiaoxinyi FYI... I ran into a similar situation when using the latest MySQL image from Docker (8.0.1). The problem goes away w/ 8.0.0.

hach-que commented 7 years ago

Closing this as there is nothing to action here.