My database can't connect.

General discussions around KeyHelp.
Post Reply
akong77
KeyHelp Translator
Posts: 64
Joined: Mon 2. Aug 2021, 07:39

My database can't connect.

Post by akong77 »

I use this command.
root@panel:~# keyhelp-toolbox

Warning: MySQL - Connection Error: Access denied for user 'keyhelp'@'localhost' to database 'keyhelp' in /home/keyhelp/www/keyhelp/core-old/pending/DBConnection.php on line 338

Fatal error: Uncaught Error: Call to a member function query() on null in /home/keyhelp/www/keyhelp/core-old/pending/DBConnection.php:114
Stack trace:
#0 /home/keyhelp/www/keyhelp/core-old/pending/DBConnection.php(65): DBConnection->connect()
#1 /home/keyhelp/www/keyhelp/core-old/pending/DBConnection.php(374): DBConnection->__construct()
#2 /home/keyhelp/www/keyhelp/bin/keyhelp_toolbox.php(35): DBConnection::getConnection()
#3 {main}
thrown in /home/keyhelp/www/keyhelp/core-old/pending/DBConnection.php on line 114
How to fix it?
akong77
KeyHelp Translator
Posts: 64
Joined: Mon 2. Aug 2021, 07:39

Re: My database can't connect.

Post by akong77 »

I use follow step to fix it.
root@panel:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 329
Server version: 10.6.18-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> SELECT user, host FROM mysql.user WHERE user = 'keyhelp';
+---------+-----------+
| User | Host |
+---------+-----------+
| keyhelp | localhost |
+---------+-----------+
1 row in set (0.001 sec)

MariaDB [(none)]> SHOW GRANTS FOR 'keyhelp'@'localhost';
+----------------------------------------------------------------------------------------------------------------+
| Grants for keyhelp@localhost |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `keyhelp`@`localhost` IDENTIFIED BY PASSWORD '*4C5CB14A67713E8C5ED26B7DF1033C08D9A7B095' |
+----------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON keyhelp.* TO 'keyhelp'@'localhost' IDENTIFIED BY 'passowrd';
Query OK, 0 rows affected (0.074 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit
Bye
It's can fix it.But why?
akong77
KeyHelp Translator
Posts: 64
Joined: Mon 2. Aug 2021, 07:39

Re: My database can't connect.

Post by akong77 »

I got another error for webmail.
Webmail will got error message.
Oops... something went wrong!

An internal error has occurred. Your request cannot be processed at this time.

For administrators: Please check the application and/or server error logs for more information
How to fix it?
User avatar
Alexander
Keyweb AG
Posts: 4340
Joined: Wed 20. Jan 2016, 02:23

Re: My database can't connect.

Post by Alexander »

The database passwords seems to be no no longer in sync with the passwords defined in various configuration files.
What have you done to your server?


You have to make sure that the passwords in these files:

KeyHelp password:
/etc/keyhelp/config/config.json
/home/keyhelp/www/roundcube/plugins/password/config.inc.php
/etc/proftpd/sql.conf
/etc/postfix/mysql-virtual-*
/etc/dovecot/dovecot-sql.conf
/etc/amavis/conf.d/50-user (Depending on your OS, if you have that file)

Roundcube password:
/home/keyhelp/www/roundcube/config/config.inc.php

SnappyMail password:
/home/keyhelp/www/snappymail/data/_data_/_default_/configs/application.ini

PhpMyAdmin password:
/home/keyhelp/www/phpmyadmin/config.inc.php


Are in sync with the database users:

keyhelp,
keyhelp_root,
roundcube,
snappymail,
phpmyadmin
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
akong77
KeyHelp Translator
Posts: 64
Joined: Mon 2. Aug 2021, 07:39

Re: My database can't connect.

Post by akong77 »

I have some question.
1. I use this command
mysql -u root -p and not input any password.It's can login mysql.Why?
I also check another keyhelp server.It's the same not need input any password.
2. I use GRANT ALL PRIVILEGES ON keyhelp.* TO 'keyhelp'@'localhost' IDENTIFIED BY 'passowrd'; this command to fix.
Is this right solution?
3 I fix webmail use follow command.
GRANT ALL PRIVILEGES ON roundcube.* TO 'roundcube'@'localhost';
Is this right solution?
Thanks a lot.
User avatar
Alexander
Keyweb AG
Posts: 4340
Joined: Wed 20. Jan 2016, 02:23

Re: My database can't connect.

Post by Alexander »

1. I use this command
mysql -u root -p and not input any password.It's can login mysql.Why?
I also check another keyhelp server.It's the same not need input any password.
This is a default behaviour of your operating system + MariaDB/MySQL that was introduced around the time Ubuntu 16/Ubuntu 18 were released. This has nothing to do with KeyHelp.
It allows you to log into the database without a password if you are logged into the server as root.

2. I use GRANT ALL PRIVILEGES ON keyhelp.* TO 'keyhelp'@'localhost' IDENTIFIED BY 'passowrd'; this command to fix.
Is this right solution?
For the "keyhelp" user:

Code: Select all

GRANT ALL PRIVILEGES ON keyhelp.* TO 'keyhelp'@'localhost' IDENTIFIED BY "..."
For the "keyhelp_root" user

Code: Select all

GRANT ALL PRIVILEGES ON *.* TO 'keyhelp_root'@'localhost' IDENTIFIED BY "..." WITH GRANT OPTION

3 I fix webmail use follow command.
GRANT ALL PRIVILEGES ON roundcube.* TO 'roundcube'@'localhost';
Is this right solution?
An "IDENTIFIED BY '....'" is missing, but other than that, yes, this is correct.
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
Post Reply