Symptoms

When accessing phpMyAdmin, the interface fails to load and provides the following error instead:

mysqli_sql_exception: Permission denied

 

Description

This will often happen when the permissions for the MySQL data directory have been changed to the incorrect value.

 

Workaround

Ensure that the MySQL data directory has the expected permissions:

  1. Access the server via SSH as the root user
  2. Use the following command to check the permissions and ownership of the MySQL data directory:
    [root@server ~]# stat /var/lib/mysql
    File: /var/lib/mysql
    Size: 4096 Blocks: 8 IO Block: 4096 directory
    Device: fd03h/64771d Inode: 50337511 Links: 9
    Access: (0751/drwxr-x--x) Uid: ( 27/ mysql) Gid: ( 27/ mysql)
    Access: 20XX-01-01 00:00:00 -0000
    Modify: 20XX-01-01 00:00:00 -0000
    Change: 20XX-01-01 00:00:00 -0000
    Birth: 20XX-01-01 00:00:00 -0000
    The permissions and ownership above are the default; Access should be set to 751, and the UID/GID owner should be set to "mysql"
  3. If the ownership is not set to 751, use the following command to correct it:
    chmod -v 0751 /var/lib/mysql
  4. If the ownership is not correct, use the following command to correct it:
    chown -v mysql:mysql /var/lib/mysql
  5. With the permissions corrected, access phpMyAdmin as normal