I removed the root account in mysql in an attempt to harden the server. I have created another user (let's call it AdminAccount) and granted all privileges on % and localhost. Since then, I have been getting the following error when I login to phpmyadmin:
mysqli::real_connect(): (HY000/1045): Access denied for user 'AdminAccount'@'localhost' (using password: YES) Connection for controluser as defined in your configuration failed.
This error appears at the bottom of each screen although I have not seen any loss of functionality - all pages are working and I can work on any of the databases. Here are the checks I did:
MariaDB [(none)]> show grants for 'root'@'localhost';
+-------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `root`@`localhost` IDENTIFIED BY PASSWORD '*48xxxxxxxxxxxxxx6' |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
MariaDB [(none)]> show grants for 'root'@'%';
ERROR 1141 (42000): There is no such grant defined for user 'root' on host '%'
MariaDB [(none)]> show grants for 'AdminAccount'@'localhost';
+---------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for AdminAccount@localhost |
+---------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `AdminAccount`@`localhost` IDENTIFIED BY PASSWORD '*4xxxxxxxxxxxxxxxxxxxxx6' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `phpmyadmin`.* TO `AdminAccount`@`localhost` |
+---------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
MariaDB [(none)]> show grants for 'AdminAccount'@'%';
+-------------------------------------------------------------------------------------------------------------------------------------+
| Grants for AdminAccount@% |
+-------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `AdminAccount`@`%` IDENTIFIED BY PASSWORD '*48xxxxxxxxxxxxxxxxxxxxx6' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
After this, I went ahead and added the following:
MariaDB [(none)]> GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
I also tried
DROP USER ''@'localhost';
DROP USER ''@'%';
based on this link. But I didn't have that problem and it said I don't have any such user.
Nothing has changed in phpmyadmin despite the above interventions. What did I do wrong and how can I fix it?
My configuration:
Database server
Server: Localhost via UNIX socket
Server type: MariaDB
Server connection: SSL is not being used Documentation
Server version: 10.5.18-MariaDB-0+deb11u1 - Debian 11
Protocol version: 10
User: AccountAdmin@localhost
Server charset: UTF-8 Unicode (utf8mb4)
Web server
Apache/2.4.54 (Debian)
Database client version: libmysql - mysqlnd 8.2.1
PHP extension: mysqli curl mbstring
PHP version: 8.2.1
phpMyAdmin
Version information: 5.1.4deb1~bpo11+1
Edit: I found a potential problem. I was told to look for the following:
$cfg['Servers'][$i]['user'] = 'your_username';
$cfg['Servers'][$i]['password'] = 'your_password';
in the config file for phpmyadmin. However, in /etc/phpmyadmin/config.inc.php those lines do not exist. Instead I found the following:
$cfg['Servers'][$i]['controluser'] = $dbuser;
$cfg['Servers'][$i]['controlpass'] = $dbpass;
but what is $dbuser and $dbpass? I didn't find those variables anywhere in that file or in any other file. I used grep to search all dirs and subdirs under /etc/phpmyadmin