Errcode: 13 - permission denied phpmyadmin

Symptoms

  • Unable to log in to Plesk, the following error appears:
    ERROR: PleskDBException: Unable to connect to database: mysql_connect(): Permission denied /var/lib/mysql/mysql.sock (Error code: 2002). 

    ERROR: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Permission denied' in /usr/local/psa/admin/externals/Zend/Db/Adapter/Pdo/Abstract.php
  • Unable to start
    mariadb
    service with the following error:

    systemd[1]: Starting MariaDB database server...
    mariadb-prepare-db-dir[4030]: chmod: changing permissions of Б─≤/var/lib/mysqlБ─≥: Operation not permitted
    mariadb-prepare-db-dir[4030]: Initializing MySQL database
    mariadb-prepare-db-dir[4030]: chown: changing ownership of Б─≤/var/lib/mysqlБ─≥: Operation not permitted
    mariadb-prepare-db-dir[4030]: Cannot change ownership of the database directories to the 'mysql'
    mariadb-prepare-db-dir[4030]: user. Check that you have the necessary permissions and try again.
    mariadb-prepare-db-dir[4030]: Initialization of MySQL database failed.
  • Unable to access MySQL database. The following error appears if trying to log in to database using
    mysql
    utility:

    ERROR 1018 (HY000): Can't read dir of './db-name/' (errno: 13)
  • The permissions of
    /var/lib/mysql/
    are different from listed below:

    # ls -ld /var/lib/mysql
    drwxr-xr-x 5 mysql mysql 4096 Apr 20 13:05 /var/lib/mysql

Cause

Incorrect permissions for
/var/lib/mysql/
directory and its subdirectories.

Resolution

  1. Log in to the server via SSH;

    Note: if direct SSH access to the server is not possible, contact server administrator for further assistance.

  2. Set proper owner to the directory and files:

    # chown -R mysql:mysql /var/lib/mysql
    # find /var/lib/mysql/* -type d -exec chmod 0700 {} ;
    # find /var/lib/mysql/* -type f -exec chmod 0660 {} ;

    For Debian/Ubuntu

    # chmod 700 /var/lib/mysql

    For RHEL/CentOS

    # chmod 755 /var/lib/mysql

I am getting *Job for mysql.service failed because the control process exited with error code.

See "systemctl status mysql.service" and "journalctl -xe" for details.* 

When I run that command I get

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-04-20 09:32:04 CDT; 19s ago
  Process: 7287 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
  Process: 7295 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
 Main PID: 7295 (code=exited, status=1/FAILURE)
   Status: "Server startup in progress"
    Error: 13 (Permission denied)

Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Service RestartSec=100ms expired, scheduling restart.
Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Apr 20 09:32:04 sturtz.ml systemd[1]: Stopped MySQL Community Server.
Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Start request repeated too quickly.
Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 20 09:32:04 sturtz.ml systemd[1]: Failed to start MySQL Community Server.*

asked Apr 20, 2020 at 14:33

Errcode: 13 - permission denied phpmyadmin

NateNate

4921 gold badge6 silver badges26 bronze badges

5

I ran the following and it worked on Ubuntu Server 19.10:

sudo chown -R mysql:mysql /var/lib/mysql/

Errcode: 13 - permission denied phpmyadmin

answered Apr 20, 2020 at 14:55

Errcode: 13 - permission denied phpmyadmin

NateNate

4921 gold badge6 silver badges26 bronze badges

1

You can logging to the /var/log/mysqld path and check the mysql error.

tail -f /var/log/mysqld.log

Then you can see the permission error path. Example as below.

"2021-01-13T04:46:06.336009Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '**/var/run/mysqld/mysqld.pid**' (OS errno 13 - Permission denied)"

Now you can give access permission to above path using below command:

chown -R mysql:mysql /var/run/mysqld/

After that, try to start mysqld service .

Kevin Bowen

18.9k55 gold badges73 silver badges80 bronze badges

answered Jan 13, 2021 at 4:51

How do I fix access denied in phpMyAdmin?

This can be easily configured using the following steps:.
Step 1: Open MySql..
Step 2: Through phpMyAdmin/librarires, you should edit config. ... .
Step 3: Concerning the server commands, change $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = 'Localhost';.

How do I grant access to phpMyAdmin?

phpmyadmin Getting started with phpmyadmin How to create a database and grant privileges for database user..
Login using username root and root password..
Click on Databases tab..
Enter database name, select collation (you may leave it to default) and click create..
Click on Privileges tab and select "Add user account"..

Why is phpMyAdmin not working?

You may receive an error message stating that phpMyAdmin needs a PHP version within a specific range. This might happen if you're running an outdated version of PHP, or a new update is not compatible with your version of MAMP. In this case, you”ll need to change the PHP version of your MAMP application.

How do I fix XAMPP Access Denied?

So open your XAMPP folder and find a file named xampp-control.exe. right-click on this file and Select Properties a tab will open like and select Compatibility and check “Run this program as an administrator” and click on the Ok button.