Closed bhargavjoshi closed 7 years ago
It looks like you don't have MYSQL_USER=phabricator
or MYSQL_PASSWORD=phabricator
in the phabricator section of your config. Note this line in the output:
phabricator_1 | + mysqlcheck --host= --port= --user= --password= --databases phabricator_search
phabricator_1 | mysqlcheck: Got error: 2002: Can't connect to local MySQL server...
I think this case is still relevant though, because I'm getting the same error with this configuration:
version: '2'
services:
phabricator:
ports:
- "62443:443"
- "62080:80"
- "62022:22"
depends_on:
- mysql
links:
- mysql
environment:
- MYSQL_LINKED_CONTAINER=mysql
- MYSQL_USER=phabricator
- MYSQL_PASS=phabricator
image: hachque/phabricator
mysql:
volumes:
- /mnt/docker/phabricator/mysql:/var/lib/mysql
image: mysql:5.7.16
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_USER=phabricator
- MYSQL_PASSWORD=phabricator
with this error
phabricator_1 | + mysqlcheck --host= --port= --user=phabricator --password=phabricator --databases phabricator_search
phabricator_1 | mysqlcheck: Got error: 2002: Can't connect to local MySQL server
It looks like the MYSQL_LINKED_CONTAINER
isn't functioning as expected.
I added this
- MYSQL_USER=phabricator
- MYSQL_PASS=phabricator
Still getting the following error, does it still requires host and port?
If so what should be the value?
mysqlcheck --host= --port= --user=phabricator --password=phabricator --databases phabricator_search
phabricator_1 | mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2 "No such file or directory") when trying to connect
phabricator_1 | + true
I don't know. I have the same problem. MYSQL_LINKED_CONTAINER=mysql
should fill in the host and port automatically, but it's not. If someone more knowledgeable about this project doesn't look at it, I'll start poking around in the source.
I think this is because the version of Docker you have no longer exposes linked container environment variables. I was under the impression that someone had sent a fix through so that MYSQL_LINKED_CONTAINER
did the right thing on newer versions of Docker, but it looks like that hasn't happened.
On newer versions of Docker you can just do MYSQL_HOST=linkedcontainername
and Docker's internal DNS should resolve it (in the Docker compose case I think it would be mysql
).
I pushed a potential fix here: https://github.com/hach-que-docker/phabricator/tree/untested-fix.
Can someone using Docker compose or otherwise having issues with MYSQL_LINKED_CONTAINER
run docker build . -t local-phabricator
in that branch, then test starting local-phabricator
with the MYSQL_LINKED_CONTAINER
variable on a their version of Docker to see if it resolves the issue?
Tested it, I am still getting the same error. Here is a snippet
+ mysqlcheck --host= --port= --user= --password= --databases phabricator_search
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2 "No such file or directory") when trying to connect
+ true
+ /srv/phabricator/phabricator/bin/storage upgrade --force
MySQL Credentials Not Configured
Unable to connect to MySQL using the configured credentials. You must
configure standard credentials before you can upgrade storage. Run these
commands to set up credentials:
phabricator/ $ ./bin/config set mysql.host __host__
phabricator/ $ ./bin/config set mysql.user __username__
phabricator/ $ ./bin/config set mysql.pass __password__
These standard credentials are separate from any administrative credentials
provided to this command with __--user__ or __--password__, and must be
configured correctly before you can proceed.
Raw MySQL Error: Attempt to connect to root@localhost failed with error
#2002: No such file or directory.
[ FAILED ] /etc/init.simple/10-boot-conf
Does it work if you just replace MYSQL_LINKED_CONTAINER
with MYSQL_HOST
?
On Thu., 10 Nov. 2016, 6:35 am bhargavjoshi, notifications@github.com wrote:
Tested it, I am still getting the same error. Here is a snippet
- mysqlcheck --host= --port= --user= --password= --databases phabricator_search mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2 "No such file or directory") when trying to connect
- true
- /srv/phabricator/phabricator/bin/storage upgrade --force MySQL Credentials Not Configured
Unable to connect to MySQL using the configured credentials. You must configure standard credentials before you can upgrade storage. Run these commands to set up credentials:
phabricator/ $ ./bin/config set mysql.host host phabricator/ $ ./bin/config set mysql.user username phabricator/ $ ./bin/config set mysql.pass password
These standard credentials are separate from any administrative credentials provided to this command with --user or --password, and must be configured correctly before you can proceed.
Raw MySQL Error: Attempt to connect to root@localhost failed with error
2002: No such file or directory.
[ FAILED ] /etc/init.simple/10-boot-conf
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/hach-que-docker/phabricator/issues/56#issuecomment-259504704, or mute the thread https://github.com/notifications/unsubscribe-auth/AAez-hq1ghta0P74yspTo3_pPYo-cm_pks5q8iBigaJpZM4Kpq24 .
The untested-fix branch errors out because I don't seem to have preflight.
Replacing MYSQL_LINKED_CONTAINER
with MYSQL_HOST
results in an access denied which is progress, I think.
[34mphabricator_1 |[0m + '[' '' == true ']'
[34mphabricator_1 |[0m + pushd /srv/phabricator/phabricator
[34mphabricator_1 |[0m + '[' mysql '!=' '' ']'
[34mphabricator_1 |[0m + sudo -u git ./bin/config set mysql.host mysql
[34mphabricator_1 |[0m [2016-11-10 05:29:05] EXCEPTION: (AphrontAccessDeniedQueryException) #1044: Access denied for user 'phabricator'@'%' to database 'phabricator_config' at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:319]
[34mphabricator_1 |[0m arcanist(head=master, ref.master=fad85844314b), phabricator(head=master, ref.master=e9b861ff1583), phutil(head=master, ref.master=2b7b1007bf87)
[34mphabricator_1 |[0m #0 AphrontBaseMySQLDatabaseConnection::throwCommonException(integer, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:334]
[34mphabricator_1 |[0m #1 AphrontBaseMySQLDatabaseConnection::throwConnectionException(integer, string, string, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:76]
[34mphabricator_1 |[0m #2 AphrontMySQLiDatabaseConnection::connect() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:101]
[34mphabricator_1 |[0m #3 AphrontBaseMySQLDatabaseConnection::establishConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:124]
[34mphabricator_1 |[0m #4 AphrontBaseMySQLDatabaseConnection::requireConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:15]
[34mphabricator_1 |[0m #5 AphrontMySQLiDatabaseConnection::escapeBinaryString(string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:11]
[34mphabricator_1 |[0m #6 AphrontMySQLiDatabaseConnection::escapeUTF8String(string) called at [<phutil>/src/xsprintf/qsprintf.php:178]
[34mphabricator_1 |[0m #7 xsprintf_query(AphrontMySQLiDatabaseConnection, string, integer, string, integer) called at [<phutil>/src/xsprintf/xsprintf.php:70]
[34mphabricator_1 |[0m #8 xsprintf(string, AphrontMySQLiDatabaseConnection, array) called at [<phutil>/src/xsprintf/qsprintf.php:64]
[34mphabricator_1 |[0m #9 qsprintf(AphrontMySQLiDatabaseConnection, string, string, string, string)
[34mphabricator_1 |[0m #10 call_user_func_array(string, array) called at [<phutil>/src/xsprintf/queryfx.php:5]
[34mphabricator_1 |[0m #11 queryfx(AphrontMySQLiDatabaseConnection, string, string, string, string)
[34mphabricator_1 |[0m #12 call_user_func_array(string, array) called at [<phutil>/src/xsprintf/queryfx.php:13]
[34mphabricator_1 |[0m #13 queryfx_all(AphrontMySQLiDatabaseConnection, string, string, string, string)
[34mphabricator_1 |[0m #14 call_user_func_array(string, array) called at [<phutil>/src/aphront/storage/connection/AphrontDatabaseConnection.php:52]
[34mphabricator_1 |[0m #15 AphrontDatabaseConnection::queryData(string, string, string, string)
[34mphabricator_1 |[0m #16 call_user_func_array(array, array) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:535]
[34mphabricator_1 |[0m #17 LiskDAO::loadRawDataWhere(string, string)
[34mphabricator_1 |[0m #18 call_user_func_array(array, array) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:476]
[34mphabricator_1 |[0m #19 LiskDAO::loadAllWhere(string, string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:19]
[34mphabricator_1 |[0m #20 PhabricatorConfigDatabaseSource::loadConfig(string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:7]
[34mphabricator_1 |[0m #21 PhabricatorConfigDatabaseSource::__construct(string) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:238]
[34mphabricator_1 |[0m #22 PhabricatorEnv::buildConfigurationSourceStack(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:95]
[34mphabricator_1 |[0m #23 PhabricatorEnv::initializeCommonEnvironment(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:75]
[34mphabricator_1 |[0m #24 PhabricatorEnv::initializeScriptEnvironment(boolean) called at [<phabricator>/scripts/init/lib.php:22]
[34mphabricator_1 |[0m #25 init_phabricator_script(array) called at [<phabricator>/scripts/init/init-setup.php:12]
[34mphabricator_1 |[0m #26 require_once(string) called at [<phabricator>/scripts/setup/manage_config.php:5]
[34mphabricator_1 |[0m [ FAILED ] /etc/init.simple/10-boot-conf
Gracefully stopping... (press Ctrl+C again to force)
I've run out of time today. I'll debug more tomorrow. Thanks for the help!
Hmm, that just looks like a permission problem with the MySQL database itself - I mean it clearly has the username at this point (and presumably the password). Can you verify that you can connect to the database with those credentials?
I setup the mysql database as a docker container with a user/password in the env variables. I tried it using the root password, and it connected. Thanks for helping me through this, I guess it's a problem with how I'm using mysql user setup on initialization.
I don't know if @bhargavjoshi 's issue is resolved, but mine is.
Hi,
I had the same problem and I hacked it in a similar way. I entered into the mysql docker using "docker exec" and using root and command-line "mysql" I checked user table. User phabricator didn't have any privilege in there so I gave him all the privileges. After that I relaunched docker-compose and then it seems to work. Not sure what's the correct solution for the docker-compose file.
Yeah, the Docker compose support was contributed by another person. I don't personally use Docker compose, so I can't offer much support beyond issues that affect the Phabricator container itself.
I was able to fix it by creating a new flavor of mysql:
FROM mysql:5.7.14
COPY grant_privileges.sql /docker-entrypoint-initdb.d
Where grant_privileges.sql has:
GRANT ALL PRIVILEGES ON * . * TO 'phabricator';
However, there is some problem when stopping and restarting the containers (docker-compose down; docker-compose up). Sometimes it just doesn't work complaining that it cannot find the mysql instance.
I got a little farther with fewer manual hacks, but I'm still stuck. I did the following:
sed -i 's/MYSQL_LINKED_CONTAINER/MYSQL_HOST/' docker-compose.yml
awk 'BEGIN {t=0}; { print }; /volumes:/ { t++; if ( t==2) { print " - ./initdb:/docker-entrypoint-initdb.d" } }' docker-compose.yml > _
mv _ docker-compose.yml
mkdir initdb
cat > initdb/create_user.sql <<EOL
GRANT ALL PRIVILEGES ON * . * TO 'phabricator'@'%';
EOL
Maybe mysql isn't picking up the create_user.sql
file; I'm now getting this (abbreviated) error, which at least feels like progress:
phabricator_1 | [2016-11-15 11:37:33] EXCEPTION: (AphrontAccessDeniedQueryException) #1044: Access denied for user 'phabricator'@'%' to database 'phabricator_config' at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:319]
phabricator_1 | arcanist(head=master, ref.master=fad85844314b), phabricator(head=master, ref.master=d5a72ca98ed2), phutil(head=master, ref.master=162c55d991df)
...
phabricator_1 | #26 require_once(string) called at [<phabricator>/scripts/setup/manage_config.php:5]
phabricator_1 | [ FAILED ] /etc/init.simple/10-boot-conf
Hi,
You can try exactly my solution, using a new Dockerfile to build a mysql image derived from the original. That worked for me (although your solution looks basically the same as mine).
To debug your problem...
To check the privileges are OK just enter in the mysql docker:
docker exec -it containerID env TERM=xterm bash
Note that containerID above has to be changed by the correct ID that "docker ps" will give you.
Once you're inside just use mysql directly:
mysql -u root -p
This will request you a password that is output by the screen when you first initialize the mysql container (and you have MYSQL_RANDOM_ROOT_PASSWORD=yes). You can also disable the RANDOM_ROOT_PASSWORD and force the MYSQL_ROOT_PASSWORD manually in the docker compose.
Once you're able to enter docker instance you can then check the user table inside mysql database.
mysql> use mysql;
mysql> SELECT * FROM user;
That should show you the privileges for all users, included phabricator (it should exist). If that shows basically N for everything then grant the privileges there.
mysql> GRANT ALL PRIVILEGES ON * . * TO 'phabricator';
mysql> SELECT * FROM user;
At this point it should show Y for basically everything. Stop the mysql, restart phabricator (docker-compose up) and check if you get further.
Hope this helps.
NOTE: To do the debug and modifications to the mysql instance I first commented out the whole phabricator section of the docker-compose file. Then the docker-compose up will just bring up the mysql. After the mysql container is modified you can reenable the phabricator part and the docker-compose up should use your already modified mysql container.
After playing around with docker-compose
for a bit, I pushed a fix for this issue. If you're still having trouble connecting, try deleting /srv/docker/phabricator/mysql
(assuming you have no data you want to keep!), and everything should start up correctly when you do docker-compose up
.
Sorry I am just getting started to learn docker,
I am using docker-compose, I don't know what I am doing wrong, here is my docker file.
Here is the error messages I am getting