sysPass icon indicating copy to clipboard operation
sysPass copied to clipboard

Unable to connect to database at install

Open lin-unix opened this issue 7 years ago • 20 comments

sysPass Version 3.0.5

Describe the question Now that I have sysPass installed in Docker, I'm having trouble getting it to connect to the database.

Usernames and passwords are all entered into the form. Database server is localhost. Database name is the default 'syspass'. When I click Install, I get this error:

"Unable to connect to DB Error 2002: SQLSTATE[HY000] [2002] No such file or directory"

Platform (please complete the following information):

  • OS: Debian
  • 9

lin-unix avatar Mar 14 '19 17:03 lin-unix

I think I had the same error. Does it make any difference if you try 127.0.0.1 instead of localhost?

cRaZy-bisCuiT avatar Mar 15 '19 08:03 cRaZy-bisCuiT

Dude, I am getting this error also. Please, follow the syspass.log: root@sjcsrvsyspass:/# tail -f /var/www/html/syspass/app/config/syspass.log #5 /var/www/html/syspass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #6 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #7 /var/www/html/syspass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #8 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #9 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #11 /var/www/html/syspass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #12 /var/www/html/syspass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #13 /var/www/html/syspass/index.php(28): require('/var/www/html/s...') #14 {main} 2019-03-15 09:23:52 [INFO] [SP\Core\PhpExtensionChecker::checkMandatory] Extensions checked 2019-03-15 09:23:52 [INFO] [SP\Core\UI\Theme::initIcons] Loaded icons cache 2019-03-15 09:23:52 [INFO] [SP\Core\Acl\Actions::loadCache] Loaded actions cache 2019-03-15 09:23:53 [EXCEPTION] [N/A] Unable to connect to DB #0 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(94): SP\Storage\Database\MySQLHandler->getConnectionSimple() #1 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(72): SP\Services\Install\MySQL->connectDatabase() #2 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(263): SP\Services\Install\MySQL->__construct(Object(SP\Services\Install\InstallData), Object(SP\Config\ConfigData)) #3 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(181): SP\Services\Install\Installer->setupDb() #4 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(93): SP\Services\Install\Installer->install() #5 /var/www/html/syspass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #6 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #7 /var/www/html/syspass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #8 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #9 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #11 /var/www/html/syspass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #12 /var/www/html/syspass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #13 /var/www/html/syspass/index.php(28): require('/var/www/html/s...') #14 {main} 2019-03-15 09:23:53 [EXCEPTION] [N/A] (P) SQLSTATE[HY000] [1045] Access denied for user 'usr_db_syspass'@'localhost' (using password: YES) #0 /var/www/html/syspass/lib/SP/Storage/Database/MySQLHandler.php(173): PDO->__construct('mysql:charset=u...', 'usr_db_syspass', 'wc67fIXj', Array) #1 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(94): SP\Storage\Database\MySQLHandler->getConnectionSimple() #2 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(72): SP\Services\Install\MySQL->connectDatabase() #3 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(263): SP\Services\Install\MySQL->__construct(Object(SP\Services\Install\InstallData), Object(SP\Config\ConfigData)) #4 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(181): SP\Services\Install\Installer->setupDb() #5 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(93): SP\Services\Install\Installer->install() #6 /var/www/html/syspass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #7 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #8 /var/www/html/syspass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #9 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #11 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #12 /var/www/html/syspass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #13 /var/www/html/syspass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #14 /var/www/html/syspass/index.php(28): require('/var/www/html/s...') #15 {main} 2019-03-15 09:23:53 [EXCEPTION] [N/A] Unable to connect to DB #0 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(72): SP\Services\Install\MySQL->connectDatabase() #1 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(263): SP\Services\Install\MySQL->__construct(Object(SP\Services\Install\InstallData), Object(SP\Config\ConfigData)) #2 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(181): SP\Services\Install\Installer->setupDb() #3 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(93): SP\Services\Install\Installer->install() #4 /var/www/html/syspass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #5 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #6 /var/www/html/syspass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #7 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #8 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #9 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/syspass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #11 /var/www/html/syspass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #12 /var/www/html/syspass/index.php(28): require('/var/www/html/s...') #13 {main} 2019-03-15 09:23:53 [EXCEPTION] [N/A] (P) Unable to connect to DB #0 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(94): SP\Storage\Database\MySQLHandler->getConnectionSimple() #1 /var/www/html/syspass/lib/SP/Services/Install/MySQL.php(72): SP\Services\Install\MySQL->connectDatabase() #2 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(263): SP\Services\Install\MySQL->__construct(Object(SP\Services\Install\InstallData), Object(SP\Config\ConfigData)) #3 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(181): SP\Services\Install\Installer->setupDb() #4 /var/www/html/syspass/lib/SP/Services/Install/Installer.php(93): SP\Services\Install\Installer->install() #5 /var/www/html/syspass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #6 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #7 /var/www/html/syspass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #8 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #9 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/syspass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #11 /var/www/html/syspass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #12 /var/www/html/syspass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #13 /var/www/html/syspass/index.php(28): require('/var/www/html/s...') #14 {main}

Hope can get the solution for this case.

Thanks

brunobva avatar Mar 15 '19 12:03 brunobva

I think I had the same error. Does it make any difference if you try 127.0.0.1 instead of localhost?

In my case, I tried both... :(

Still getting problem

brunobva avatar Mar 15 '19 12:03 brunobva

I'm getting a different error message:

2019-03-15 13:39:00 [EXCEPTION] [N/A] Unable to connect to DB #0 /var/www/html/sysPass/lib/SP/Services/Install/MySQL.php(72): SP\Services\Install\MySQL->connectDatabase() #1 /var/www/html/sysPass/lib/SP/Services/Install/Installer.php(263): SP\Services\Install\MySQL->__construct(Object(SP\Services\Install\InstallData), Object(SP\Config\ConfigData)) #2 /var/www/html/sysPass/lib/SP/Services/Install/Installer.php(181): SP\Services\Install\Installer->setupDb() #3 /var/www/html/sysPass/lib/SP/Services/Install/Installer.php(93): SP\Services\Install\Installer->install() #4 /var/www/html/sysPass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #5 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #6 /var/www/html/sysPass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #7 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #8 /var/www/html/sysPass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #9 /var/www/html/sysPass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/sysPass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #11 /var/www/html/sysPass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #12 /var/www/html/sysPass/index.php(28): require('/var/www/html/s...') #13 {main} 2019-03-15 13:39:00 [EXCEPTION] [N/A] (P) Unable to connect to DB #0 /var/www/html/sysPass/lib/SP/Services/Install/MySQL.php(94): SP\Storage\Database\MySQLHandler->getConnectionSimple() #1 /var/www/html/sysPass/lib/SP/Services/Install/MySQL.php(72): SP\Services\Install\MySQL->connectDatabase() #2 /var/www/html/sysPass/lib/SP/Services/Install/Installer.php(263): SP\Services\Install\MySQL->__construct(Object(SP\Services\Install\InstallData), Object(SP\Config\ConfigData)) #3 /var/www/html/sysPass/lib/SP/Services/Install/Installer.php(181): SP\Services\Install\Installer->setupDb() #4 /var/www/html/sysPass/lib/SP/Services/Install/Installer.php(93): SP\Services\Install\Installer->install() #5 /var/www/html/sysPass/app/modules/web/Controllers/InstallController.php(87): SP\Services\Install\Installer->run(Object(SP\Services\Install\InstallData)) #6 [internal function]: SP\Modules\Web\Controllers\InstallController->installAction() #7 /var/www/html/sysPass/lib/SP/Bootstrap.php(237): call_user_func_array(Array, Array) #8 [internal function]: SP\Bootstrap->SP{closure}(Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #9 /var/www/html/sysPass/vendor/klein/klein/src/Klein/Klein.php(886): call_user_func(Object(Closure), Object(Klein\Request), Object(Klein\Response), Object(Klein\ServiceProvider), Object(Klein\App), Object(Klein\Klein), Object(Klein\DataCollection\RouteCollection), Array) #10 /var/www/html/sysPass/vendor/klein/klein/src/Klein/Klein.php(588): Klein\Klein->handleRouteCallback(Object(Klein\Route), Object(Klein\DataCollection\RouteCollection), Array) #11 /var/www/html/sysPass/lib/SP/Bootstrap.php(461): Klein\Klein->dispatch(Object(Klein\Request)) #12 /var/www/html/sysPass/lib/Base.php(75): SP\Bootstrap::run(Object(DI\Container)) #13 /var/www/html/sysPass/index.php(28): require('/var/www/html/s...') #14 {main}

lin-unix avatar Mar 15 '19 13:03 lin-unix

I think I had the same error. Does it make any difference if you try 127.0.0.1 instead of localhost?

In my case, I tried both... :(

Still getting problem

It seems your error message is complaining about your username/password.

2019-03-15 09:23:53 [EXCEPTION] [N/A] (P) SQLSTATE[HY000] [1045] Access denied for user 'usr_db_syspass'@'localhost' (using password: YES)

I believe the default is root:syspass

lin-unix avatar Mar 15 '19 13:03 lin-unix

@cRaZy-bisCuiT Hello, database server should be installed in another container, so the connection user wouldn't be xxx@localhost it should be xxx@ip_address (or hostname) instead

Regards

nuxsmin avatar Mar 15 '19 16:03 nuxsmin

@lin-unix are you using docker too?

nuxsmin avatar Mar 15 '19 16:03 nuxsmin

@nuxsmin, I am using Docker.

lin-unix avatar Mar 15 '19 16:03 lin-unix

@lin-unix is the database installed in another container? If so, connection user won't be @localhost

nuxsmin avatar Mar 15 '19 16:03 nuxsmin

It is, what would the connection user be? I haven't edited the yml file so I have the default setup.

lin-unix avatar Mar 15 '19 18:03 lin-unix

So I changed the MariaDB port, entered in the Database Server field, entered "syspass-db" into the Database Name field and entered the default password (syspass), which got me a bit closer to solving this.

I get this error now, similar to @brunobva

2019-03-15 18:43:03 [EXCEPTION] [N/A] (P) SQLSTATE[HY000] [1045] Access denied for user 'sp_5c8bf2355ff15'@'172.18.0.1' (using password: YES)

User is set to [email protected]:32768

lin-unix avatar Mar 15 '19 18:03 lin-unix

Any ideas to help me out?

lin-unix avatar Mar 19 '19 14:03 lin-unix

I'm having a similar issue when stopping the container and restarting it.

I think the problem is that the install creates a new user with specific privileges in the mariadb and it specifies the source hostname (which for the container is a random string) and IP address, but when creating and deleting the container (es. when running docker-compose down and then docker-compose up) the IP and hostname of the docker container changes and syspass tries to connect to the db with a different user that does not exist in the DB. One workaround is to edit the config.xml and specify the mariadb root user and password

giordyb avatar Mar 22 '19 14:03 giordyb

@giordyb how would I edit the config.xml file inside an image?

lin-unix avatar Mar 22 '19 15:03 lin-unix

I used the docker-compose file that is mentioned in https://doc.syspass.org/en/3.0/installing/docker.html which creates 3 volumes, one of them contains the config.xml. From the host you can browse to the volume path (es /var/lib/docker/volumes/volumename/_data/ and edit the config.xml

giordyb avatar Mar 22 '19 16:03 giordyb

@giordyb Hello, that's the standard way but best practices about Docker, is to create a host volume (shared or not) and bind the config directory to it.

To other contributors: Please do not edit configuration stuff inside a container, neither store backups in it...

Regards

nuxsmin avatar Mar 24 '19 12:03 nuxsmin

@nuxsmin what do you mean? I am editing the file inside the dedicated volume (which is bound to the config directory), not inside the container.

giordyb avatar Mar 24 '19 12:03 giordyb

@giordyb sure, it's good way, but you need to deal with a long directory path...

Docker volumes are used to keep persistent data across the containers lifecycle, but the best way to modify container's data is binding to a host directory.

nuxsmin avatar Mar 24 '19 12:03 nuxsmin

Instead of localhost it should be syspass-db

OlympicLarry avatar Oct 28 '19 22:10 OlympicLarry

Thank you very much!!!!!

gmaciel17 avatar Apr 05 '20 21:04 gmaciel17