Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to database at install #1285

Closed
lin-unix opened this issue Mar 14, 2019 · 20 comments
Closed

Unable to connect to database at install #1285

lin-unix opened this issue Mar 14, 2019 · 20 comments

Comments

@lin-unix
Copy link

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
@cRaZy-bisCuiT
Copy link

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

@brunobva
Copy link

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
Copy link

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

@lin-unix
Copy link
Author

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
Copy link
Author

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

@nuxsmin
Copy link
Owner

nuxsmin commented Mar 15, 2019

@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
Copy link
Owner

nuxsmin commented Mar 15, 2019

@lin-unix are you using docker too?

@lin-unix
Copy link
Author

@nuxsmin, I am using Docker.

@nuxsmin
Copy link
Owner

nuxsmin commented Mar 15, 2019

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

@lin-unix
Copy link
Author

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

@lin-unix
Copy link
Author

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 root@128.100.167.xx:32768

@lin-unix
Copy link
Author

Any ideas to help me out?

@giordyb
Copy link

giordyb commented Mar 22, 2019

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

@lin-unix
Copy link
Author

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

@giordyb
Copy link

giordyb commented Mar 22, 2019

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

@nuxsmin
Copy link
Owner

nuxsmin commented Mar 24, 2019

@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

@giordyb
Copy link

giordyb commented Mar 24, 2019

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

@nuxsmin
Copy link
Owner

nuxsmin commented Mar 24, 2019

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

@OlympicLarry
Copy link

Instead of localhost it should be syspass-db

@gmaciel17
Copy link

gmaciel17 commented Apr 5, 2020

Thank you very much!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants