Can Not Connect to MySQL


#1

I try to install phabricator on vps, I use the “./bin/config set mysql” configured all mysql login information in the web this error:

Unable to connect to MySQL!

Unable to establish a connection to any database host (while trying "phabricator_config"). All masters and replicas are completely unreachable.

Make sure Phabricator and MySQL are correctly configured.

My environment: centos7.4 x86_64 installed vestacp.
nginx1.13 + php 7.1.12+ mariadb10.2.12

php module to check and install apc

This is a bug reported in ./bin/phd

[2018-01-14 08:38:50] EXCEPTION: (PhabricatorClusterStrandedException) Unable to establish a connection to any database host (while trying "phabricator_config"). All masters and replicas are completely unreachable. At [<phabricator> / src / infrastructure / storage / lisk / PhabricatorLiskDAO.php: 140]
arcanist (head = stable, ref.stable = 08674ca997b6), phabricator (head = stable, ref.stable = 53b4882b8073), phutil (head = stable, ref.stable = f3386051a959)
  # 0 PhabricatorLiskDAO :: raiseUnreachable (string) called at [<phabricator> /src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:111]
  # 1 PhabricatorLiskDAO :: newClusterConnection (string, string, string) called at [<phabricator> /src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:66]
  # 2 PhabricatorLiskDAO :: establishLiveConnection (string) called at [<phabricator> /src/infrastructure/storage/lisk/LiskDAO.php:1008]
  # 3 LiskDAO :: establishConnection (string) called at [<phabricator> /src/infrastructure/storage/lisk/LiskDAO.php:516]
  # 4 LiskDAO :: loadRawDataWhere (string, string) called at [<phabricator> /src/infrastructure/storage/lisk/LiskDAO.php:476]
  # 5 LiskDAO :: loadAllWhere (string, string) called at [<phabricator> /src/infrastructure/env/PhabricatorConfigDatabaseSource.php:19]
  # 6 PhabricatorConfigDatabaseSource :: loadConfig (string) called at [<phabricator> /src/infrastructure/env/PhabricatorConfigDatabaseSource.php:7]
  # 7 PhabricatorConfigDatabaseSource :: __ construct (string) called at [<phabricator> /src/infrastructure/env/PhabricatorEnv.php:249]
  # 8 PhabricatorEnv :: buildConfigurationSourceStack (boolean) called at [<phabricator> /src/infrastructure/env/PhabricatorEnv.php:95]
  # 9 PhabricatorEnv :: initializeCommonEnvironment (boolean) called at [<phabricator> /src/infrastructure/env/PhabricatorEnv.php:75]
  # 10 PhabricatorEnv :: initializeScriptEnvironment (boolean) called at [<phabricator> /scripts/init/lib.php:22]
  # 11 init_phabricator_script (array) called at [<phabricator> /scripts/init/init-script.php:9]
  # 12 require_once (string) called at [<phabricator> / scripts / __ init_script __. Php: 3]
  # 13 require_once (string) called at [<phabricator> /scripts/daemon/manage_daemons.php:5]

phabricator uses the “phabricator” sql user
I use the shell “mysql-u phabricator-p phabricator” to log in successfully.
Authorized phabricator users to use the full rights of the phabricator database.

Anyone can solve this problem?
If you need more logs, let me provide it.

new:
I added the option, the shell command is now
"Mysql -u phabricator -p phabricator --protocol = TCP"
Can not log in

ERROR 2002 (HY000): Can not connect to MySQL server on ‘localhost’ (111)

So is this a mariadb and phabricator communication issue?

Now re-establish the mysql user, use the shell “mysql-u phabricator-p phabricator - protocol = TCP” to log in to the account.
But phabricator web still shows “Can Not Connect to MySQL”.
Is there any other solution?


#2

Try adding --protocol=TCP to your mysql command, and see if this still works.

If it does, check again the configuration: mysql.host, mysql.pass, mysql.user and mysql.port.


#3

I added the option, the shell command is now
"Mysql -u phabricator -p phabricator --protocol = TCP"
Can not log in

ERROR 2002 (HY000): Can not connect to MySQL server on 'localhost' (111)

So is this a mariadb and phabricator communication issue?


#4

Either your mysql/mariadb configuration doesn’t allow TCP connection, or it’s using a custom port, or your user phabricator isn’t allowed to connect via TCP.

If it’s using a custom port, update mysql.port to the right one.
If it’s not using TCP at all, figure out how to enable it - it should be in a file called my.cnf somewhere, not sure where.
If it’s the user definition that’s preventing it, there should some mysql command to allow it, but I don’t know what it is.


#5

Now remove the mysql “phabricator” and add it again.
Use the shell: “mysql-u phabricator-p phabricator - protocol = TCP” to log in correctly.


mysql -u phabricator -p --protocol = TCP
Enter password:
Welcome to the MariaDB monitor. Commands end with; or \ g.
Your MariaDB connection id is 1644
Server version: 10.2.12-MariaDB MariaDB Server

Copyright © 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\ h’ for help. Type ‘\ c’ to clear the current input statement.

MariaDB [(none)]


But in webui, I still receive: Unable to connect to MySQL!


Can Not Connect to MySQL
Unable to connect to MySQL!

Unable to establish a connection to any database host (while trying “phabricator_config”). All masters and replicas are completely unreachable.

Make sure Phabricator and MySQL are correctly configured.

The current Phabricator configuration has these 4 value (s):
mysql.host "127.0.0.1"
mysql.port "3306"
mysql.user "phabricator"
mysql.pass hidden

To update these 4 value (s), run these command (s) from the command line:

phabricator / $ ./bin/config set mysql.host value
phabricator / $ ./bin/config set mysql.port value
phabricator / $ ./bin/config set mysql.user value
phabricator / $ ./bin/config set mysql.pass value


This is located at /conf/local/local.json


{
“mysql.host”: “localhost”,
“mysql.port”: “3306”,
“mysql.pass”: “phabricator”,
“mysql.user”: “phabricator”
}



#6

Not sure what could be wrong now. Try restarting nginx and php-fpm and see if it works better.


#7

After investigation to solve this problem.
phabricator need mysql is not only a single database permissions, but need to manage the entire “mysql” permissions, you need to give “phabricator” @ “loaclhost”, all the administrative privileges to be correctly written to the database.

In this issue, phabricator means “no permission mysql” instead of “Can Not Connect to MySQL”


#9

I met the same problem, Now php version is 7.1.14. mysql version is 5.7.24.Did u resolve it?