Tagged: phpmyadmin

Add basic authentication in phpMyAdmin in CentOS 7

Problem: Want to increase phpMyAdmin security, for example adding one more gateway before entering username and password in xxx/phpmyadmin

This is possible and can be achieved in two way:

Solution: first find out where the PHPMyAdmin folder

find /etc/httpd/ -print0 | xargs -0 grep phpmyadmin

then create a .htpasswd ย file for the user you want, like user1.

sudo htpasswd -c /etc/httpd/.htpasswd user1

the output will look like this:

user1:$apr1$0r/2zNGG$jopiWY3DEJd2FvZxTnugJ/

Way 1 -- edit /etc/httpd/conf/httpd.conf , change into below content:

<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
</Directory>

Way 2 -- go to phpMyAdmin folder that finds out via the previous command, add .htaccess file with below content:

AuthType Basic
AuthName "Admin Login"
AuthUserFile /etc/httpd/pma_pass
Require valid-user

Chinese Character from mysql turned into a question mark in PHP

Problem: already knew the solution below and follow them but still not work:

DB (phpmyadmin) -- change encoding to utf8_general_ci

Backend -- header(“Content-Type:text/html; charset=utf-8”); and mysqli_set_charset( “utf8”,$connect); added.

frontend -- <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

Solution: Check again if the codes and methods are all correct. This time the
mysqli_set_charset parameter is not correct -- should be mysqli_set_charset($connect,”utf8″);

Block IP in phpmyadmin

problem: block IP in phpmyadmin (or allow some IP only)

Solution: edit /etc/phpmyadmin/apache.conf file (Ubuntu) to restrict access in PHPMyAdmin. In apache.conf file, find “/usr/share/phpmyadmin” in the file and change to below

<Directory /usr/share/phpmyadmin>
Order allow,deny
Allow from 192.168.1.0/24

save it and restart apache

sudo service apache2 restart
Close Bitnami banner
Bitnami