PhpMyAdmin

phpMyAdmin is a web interface for MySQL and/or MariaDB databases.


Installation

Some Linux distributions offer a phpmyadmin package.

Manual

Fetch the latest version of the software package.

wget https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-english.zip

Create an installation directory that can be owned by the web server's user (typically www-data).

mkdir /var/www/phpmyadmin
unzip phpMyAdmin-5.0.1-english.zip
cp phpMyAdmin-5.0.1-english/* /var/www/phpmyadmin/ -r
chown www-data:www-data /var/www/phpmyadmin -R
chmod 775 /var/www/phpmyadmin -R

Update

Move the deployment to /var/www/phpmyadmin-temp and repeat the installation process for the new version. Copy the config.inc.php configuration file from the old to the new deployment. Test and, if successful, remove the old deployment.


Configuration

Nginx

For details on configuring nginx(8) for FastCGI, see here.

server {              
  listen 80;                                   
  server_name pma.my-domain.tld;                     

  root /var/www/phpmyadmin;
  index index.php;
                          
  location / {                                                
    try_files $uri $uri/ =404;       
  }                                      
  error_page 404 /index.php;

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    try_files $uri $document_root$fastcgi_script_name =404;
    fastcgi_index index.php;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
  }                         
}

Database

See MySQL or MariaDB for help with installing a database.

On first installation, the phpMyAdmin back-end tables must be configured.

mysql -u root -p < /var/www/phpmyadmin/sql/create_tables.sql

The phpMyAdmin user must be given permissions to many structural tables.

The recommended setup is:

GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
GRANT SELECT (
    Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
    Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
    File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
    Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
    Execute_priv, Repl_slave_priv, Repl_client_priv
    ) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
    ON mysql.tables_priv TO 'pma'@'localhost';

Some tutorials will also advise granting permissions to the mysql.host table... which as of MariaDB version 10.1 no longer exists.

The nuclear option is always valid:

GRANT USAGE ON *.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';


CategoryRicottone

PHP/PhpMyAdmin (last edited 2023-04-22 20:29:04 by DominicRicottone)