Learn about Centmin Mod LEMP Stack today
Become a Member

MariaDB phpmyadmin: Access denied for user 'root'@'localhost'

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by elargento, May 31, 2017.

  1. elargento

    elargento Member

    284
    16
    18
    Jan 4, 2016
    Ratings:
    +37
    Local Time:
    8:35 PM
    10
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • PHP Version Installed: 7.0.15
    I've just installed phpmyadmin but I'm unable to log in with root password:
    upload_2017-5-31_1-20-45.png
     
    Last edited by a moderator: May 31, 2017
  2. eva2000

    eva2000 Administrator Staff Member

    29,031
    6,588
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,780
    Local Time:
    9:35 AM
    Nginx 1.13.x
    MariaDB 5.5
    i removed the log info as it contains the url and http authentication login for phpmyadmin

    can you run in SSH the mysql client commands without password prompt i.e.
    Code (Text):
    mysqladmin version
    

    if it says access denied then /root/.my.cnf password is incorrect or not being read

    if you get mysql version info outputted in SSH from command then /root/.my.cnf is correct and then probably your copy/pasting incorrectly
     
  3. elargento

    elargento Member

    284
    16
    18
    Jan 4, 2016
    Ratings:
    +37
    Local Time:
    8:35 PM
    10
    Code:
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: YES)'
    
    It seems the file is not being read
     
  4. eva2000

    eva2000 Administrator Staff Member

    29,031
    6,588
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,780
    Local Time:
    9:35 AM
    Nginx 1.13.x
    MariaDB 5.5
  5. elargento

    elargento Member

    284
    16
    18
    Jan 4, 2016
    Ratings:
    +37
    Local Time:
    8:35 PM
    10
  6. eva2000

    eva2000 Administrator Staff Member

    29,031
    6,588
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,780
    Local Time:
    9:35 AM
    Nginx 1.13.x
    MariaDB 5.5
    then probably need to reset the MariaDB root password
     
  7. elargento

    elargento Member

    284
    16
    18
    Jan 4, 2016
    Ratings:
    +37
    Local Time:
    8:35 PM
    10
    Getting same error when I run
    mysql -u root -phNolA9yAnvRdOQ==

    Code:
    [13:46][root@hostname.domain.com ~]# mysqladmin version
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: YES)'
    [13:46][root@hostname.domain.com ~]# systemctl stop mariadb
    You have new mail in /var/spool/mail/root
    [14:14][root@hostname.domain.com ~]# mysqld_safe --skip-grant-tables --skip-networ                                                                                                                                                  king &
    [1] 31051
    [14:14][root@hostname.domain.com ~]# 170531 14:14:18 mysqld_safe Logging to '/var/                                                                                                                                                  lib/mysql/hostname.domain.com.err'.
    170531 14:14:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/                                                                                                                                                  mysql
    mysql -u root
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2
    Server version: 10.1.23-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('hNolA9yAnvRdOQ                                                                                                                                                  ==');
    ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables o                                                                                                                                                  ption so it cannot execute this statement
    MariaDB [(none)]> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('hNolA9yAnvRdOQ                                                                                                                                                  ==');
    ERROR 1131 (42000): You are using MariaDB as an anonymous user and anonymous use                                                                                                                                                  rs are not allowed to modify user settings
    MariaDB [(none)]> select user, host, password, plugin, authentication_string fro                                                                                                                                                  m mysql.user where user='root';
    +------+-------------------+----------+--------+-----------------------+
    | user | host              | password | plugin | authentication_string |
    +------+-------------------+----------+--------+-----------------------+
    | root | localhost         |          |        |                       |
    | root | hostname.domain.com |          |        |                       |
    | root | 127.0.0.1         |          |        |                       |
    | root | ::1               |          |        |                       |
    +------+-------------------+----------+--------+-----------------------+
    4 rows in set (0.00 sec)
    
    MariaDB [(none)]> update mysql.user set password=password('hNolA9yAnvRdOQ==') wh                                                                                                                                                  ere user='root';
    Query OK, 4 rows affected (0.00 sec)
    Rows matched: 4  Changed: 4  Warnings: 0
    
    MariaDB [(none)]> select user, host, password, plugin, authentication_string fro                                                                                                                                                  m mysql.user where user='root';
    +------+-------------------+-------------------------------------------+--------                                                                                                                                                  +-----------------------+
    | user | host              | password                                  | plugin                                                                                                                                                   | authentication_string |
    +------+-------------------+-------------------------------------------+--------                                                                                                                                                  +-----------------------+
    | root | localhost         | *CD66741D673215429FCCDB55C61826E752E07B42 |                                                                                                                                                          |                       |
    | root | hostname.domain.com | *CD66741D673215429FCCDB55C61826E752E07B42 |                                                                                                                                                          |                       |
    | root | 127.0.0.1         | *CD66741D673215429FCCDB55C61826E752E07B42 |                                                                                                                                                          |                       |
    | root | ::1               | *CD66741D673215429FCCDB55C61826E752E07B42 |                                                                                                                                                          |                       |
    +------+-------------------+-------------------------------------------+--------                                                                                                                                                  +-----------------------+
    4 rows in set (0.00 sec)
    
    MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('hNolA9yAnvRdOQ                                                                                                                                                  ==');
    ERROR 1131 (42000): You are using MariaDB as an anonymous user and anonymous use                                                                                                                                                  rs are not allowed to modify user settings
    MariaDB [(none)]> quit
    Bye
    [14:17][root@hostname.domain.com ~]# mysql -u root -phNolA9yAnvRdOQ==
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y                                                                                                                                                  ES)
    
     
  8. pamamolf

    pamamolf Well-Known Member

    2,529
    231
    63
    May 31, 2014
    Ratings:
    +394
    Local Time:
    2:35 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Just try from ssh: mysqlrestart

    and try again :)

    I had the same issue and I solve it by restarting MariaDB :)
     
    • Like Like x 1