Syspass: Unable to connect to database at install

Created on 14 Mar 2019  路  20Comments  路  Source: nuxsmin/sysPass

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
kinquestion

Most helpful comment

Instead of localhost it should be syspass-db

All 20 comments

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

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

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

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}

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

@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

@lin-unix are you using docker too?

@nuxsmin, I am using Docker.

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

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

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

Any ideas to help me out?

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 how would I edit the config.xml file inside an image?

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 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 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 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.

Instead of localhost it should be syspass-db

Thank you very much!!!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onnwe934nfajen picture onnwe934nfajen  路  6Comments

LordSchnaps picture LordSchnaps  路  4Comments

DCWNZ picture DCWNZ  路  4Comments

TheMengzor picture TheMengzor  路  3Comments

vmario89 picture vmario89  路  5Comments