UltiApex
UltiApex

Reputation: 9

Phpmyadmin. mysqli_real_connect(): (HY000/2002): Permission denied. Connection for controluser as defined in your configuration failed

I have setup my wsl environment, successfully installed Apache, mysql, and php. I can access mysql in my command line, only by using "sudo -u root -p"

I can't login to phpmyadmin,even with using the correct username and password. I've attached picture below to give a clear picture.

phpmyadmin website error

ubuntu command line error

Upvotes: -1

Views: 16608

Answers (4)

Fahim Ahmed
Fahim Ahmed

Reputation: 1

My server's Selinux was enforcing and the below parameter was disabled, so I just enabled it and could access the DB from phpMyAdmin UI.

# getsebool -a | grep httpd_can_network_connect_db

httpd_can_network_connect_db --> off

# setsebool -P httpd_can_network_connect_db 1

Upvotes: 0

Ask Congo
Ask Congo

Reputation: 21

In /etc/phpmyadmin/config.inc.php, simply uncomment line $cfg['Servers'][$i]['host'] = 'localhost';

Upvotes: 2

Usman Ahmed
Usman Ahmed

Reputation: 41

I was facing the same problem. I'm using ubuntu 20.04 using wsl. Created the lamp server with php7.3. Created new user with full privilege's. From root & from other user, getting the same error.

But I got the solution: Now first we need to install Selinux. Here are the commands:

Step 1 - Install Selinux:

sudo apt install policycoreutils selinux-utils selinux-basics

Step 2 - Activate:

sudo selinux-activate

Step 3 - Activate httpd_can_network_connect_db 1:

By default, the policy httpd_can_network_connect_db is disabled (meaning that your web server cannot contact a remote DB.) Check this via:

getsebool -a | grep httpd

If httpd_can_network_connect_db is Off, enable it via:

setsebool -P httpd_can_network_connect_db 1

Step 4 - Maybe need to change: change localhost to 127.0.0.1 in /etc/phpmyadmin/config.inc.php

$cfg['Servers'][$i]['host'] = '127.0.0.1';

Step 6 - Restart mysql & apache:

sudo service mysql start
sudi service apache2 start.

Upvotes: 3

Luis Fernando Kalfels
Luis Fernando Kalfels

Reputation: 147

In File /etc/phpmyadmin/config-db.php

change

$dbserver='localhost';

to

$dbserver='127.0.0.1';

Restart Apache2 ;-)

Upvotes: 13

Related Questions