MySQL Access Denied for root@localhost

Discussion in 'Installation/Configuration' started by 5t3f4n, Oct 19, 2021.

  1. 5t3f4n

    5t3f4n New Member

    hello!
    would need an additional pair of eyes, some hint to push me into right direction, please
    i'm following the 'Perfect Multiserver Tutorial' using Debian 10, but stalled already at setting up at first slave :(

    ISPConfig autoinstaller script runs fine and the mysql root pw for web01 is shown, and initial config is starting, BUT always stops below with 'Unable to connect to mysql server Access denied for user 'root'@'localhost' (using password: YES)'
    Code:
    MySQL master server hostname []: panel.xxx.zzz
    MySQL master server port []:
    MySQL master server root username [root]:
    MySQL master server root password []: xxxxxxxxxxxxxx
    MySQL master server database name [dbispconfig]:
    Unable to connect to mysql server Access denied for user 'root'@'localhost' (using password: YES)
    when attempting to connect to mysql on panel server from web01 the connection is established:
    Code:
    root@web01:~# mysql -u root -p -h 111.2.333.44
    Enter password: --> using the pw that was added when MySQL root user records in the master database have been created
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 218
    Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | dbispconfig        |
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    +--------------------+
    5 rows in set (0.001 sec)
    
    MariaDB [(none)]> Ctrl-C -- exit!
    Aborted
    
    What do i need to change/check/enable to debug and proceed?

    Please let me know in case further details/logs are required!

    Thanks!

    OS
    Code:
    root@web01:~# lsb_release -a
    No LSB modules are available.
    Distributor ID:    Debian
    Description:    Debian GNU/Linux 10 (buster)
    Release:    10
    Codename:    buster
    
    php version
    Code:
    root@web01:~# php -v
    PHP 7.3.31-1+0~20210923.88+debian10~1.gbpac4058 (cli) (built: Sep 23 2021 22:03:28) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.3.31-1+0~20210923.88+debian10~1.gbpac4058, Copyright (c) 1999-2018, by Zend Technologies
    
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    The error message says:
    Try to access database logging in on host panel.xxx.zzz using the mysql root user and password given.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    An ISPConfig slave server connects to two different MySQL databases, it connects to the MySQL database on the root server and it connects to his local MySQL database server. The error means that the connection to the local MySQL database server failed. If you want to test the local connection, you must use this command instead:

    mysql -u root -p -h localhost

    run on the slave node.
     
  4. 5t3f4n

    5t3f4n New Member

    thanks for your prompt replies, gentlemen
    ... and apologies for getting back with a delay - made a mistake and had to re-run the set-up using same tutorial ... but struggling again at same point!

    master: panel.example.com 192.168.1.33
    slave: web.example.com 192.168.1.34

    Code:
    MySQL master server hostname []: panel.example.com
    
    MySQL master server port []:
    
    MySQL master server root username [root]:
    
    MySQL master server root password []: --> pw added when MySQL root user records in master db were created
    
    MySQL master server database name [dbispconfig]:
    
    Unable to connect to mysql server Access denied for user 'root'@'localhost' (using password: YES)
    
    this time for both, 'panel' (master) and 'web' (slave) the localhost connection with mysql works, using:
    Code:
    mysql -u root -p -h localhost
    result panel:
    Code:
    root@panel:~# mysql -u root -p -h localhost
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2243
    Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | dbispconfig        |
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    +--------------------+
    5 rows in set (0.060 sec)
    
    MariaDB [(none)]> EXIT;
    Bye
    
    result web:
    Code:
    root@web:~# mysql -u root -p -h localhost
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 42
    Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    +--------------------+
    4 rows in set (0.000 sec)
    
    MariaDB [(none)]> EXIT;
    Bye
    
    issue comes with attempting to connect mysql from slave to master instance:

    result - attempt IP:
    Code:
    root@web:~# mysql -u root -p -h 192.168.1.33    
    Enter password: --> pw added when MySQL root user records in master db were created
    ERROR 2002 (HY000): Can't connect to MySQL server on '192.168.1.33' (115)
    result - attempt hostname:
    Code:
    root@web:~# mysql -u root -p -h panel.example.com
    Enter password: --> pw added when MySQL root user records in master db were created
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    mysql database logging does not give any hint, neither on master nor on slave:
    Code:
    tail -f /var/log/mysql/error.log
    is this now an issue related to hosts, firewall, port settings - how to debug?

    all hints welcome :)

    thanks!
     
  5. 5t3f4n

    5t3f4n New Member

    update:
    connection via IP from slave to master now working:
    Code:
    root@web:~# mysql -u root -p -h 192.168.1.33
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 4166
    Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | dbispconfig        |
    | information_schema |
    | mysql              |
    | performance_schema |
    | phpmyadmin         |
    +--------------------+
    5 rows in set (0.000 sec)
    
    MariaDB [(none)]> EXIT;
    Bye
    
    reason was the missing rule on master with ufw:
    Code:
    ufw allow from 193.162.1.32/28 to any port 3306 proto tcp
    HOWEVER, connecting to master using hostname still errors out:
    Code:
    root@web:~# mysql -u root -p -h panel.example.com
    Enter password:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    what is the missing link, how to debug?

    thanks!
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Seems as if MySQL thinks that the server hostname is localhost, this happens when you have wrong data in the hosts files. Check the /etc/hosts files on all nodes. They must contain hostnames of all other nodes and they must contain the correct IP addresses, e.g. not 127.0.0.1 for the hostname or 127.0.1.1 or something like that. 127.0.0.1 os only 'localhost' and not to be used for the IP of the server hostname.
     
    5t3f4n likes this.
  7. 5t3f4n

    5t3f4n New Member

    QUOTE="till, post: 428419, member: 3"]Check the /etc/hosts files on all nodes[/QUOTE]

    bingo!
    thanks!
    For some reason hosts had the wrong mapping - and i didn't spot it
    SOLVED
     

Share This Page