Error connecting to MySQL: Access denied for user: 'da_admin@localhost' (Using password: YES)


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » MySQL / MariaDB

Error connecting to MySQL: Access denied for user: 'da_admin@localhost' (Using password: YES)Last Modified: Aug 26, 2020, 3:14 pm
When connecting to the MySQL screens in DirectAdmin, if this error appears, that would indicated that the "da_admin" user has not been setup correctly.  To resolve this do the following.
Desired root password:
Desired da_admin password:

  1. Make sure the root mysql password works.  If you know it, skip to 2). The mysql root password can be found in the /usr/local/directadmin/scripts/setup.txt if it has not been deleted.  It's under the header "mysql=".  If it cannot be found, then mysqld we need to reset it, and may need to restarted with the --skip-grant-tables option depending on server version.
    • For MariaDB 10.4 and up, this is not required and we can gain root access without a password or restarts:

      mysql -uroot

      and reset the password with:

      SET password=PASSWORD('rootpass');

      and skip to step #2, below.
    • For MySQL 5.7 and higher on CentOS/RHEL and Debian/Ubuntu please use:

      systemctl stop mysqld
      systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
      systemctl start mysqld

    • For all the other versions of MySQL/MariaDB:

      service mysqld stop
      mysqld_safe --skip-grant-tables &

    That should start up mysql without the need for a root password. Type the following to reset the password now for MySQL 5.7 and higher:

    mysql mysql -e "UPDATE mysql.user SET authentication_string=null WHERE user='root'; FLUSH PRIVILEGES;"

    For all the other versions of MySQL/MariaDB:

    mysql mysql -e "UPDATE mysql.user SET password=PASSWORD('rootpass') WHERE user='root'; FLUSH PRIVILEGES;"

    That will reset the root password for you. That will reset the root password for you.

    For MySQL 5.7 and higheron CentOS/RHEL and Debian/Ubuntu please type the following to unset "--skip-grant-tables" option for the service:

    systemctl unset-environment MYSQLD_OPTS
    systemctl stop mysqld
    systemctl start mysqld
    mysql -uroot --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'rootpass';"

    For all the other versions of MySQL/MariaDB type:

    killall -9 mysqld_safe
    killall -9 mysqld
    service mysqld start

  2. Once the root mysql password is set and known, then you can begin the process of resetting the da_admin mysql user.
    1. Type:

      mysql -uroot -p

      Then press enter.  You'll be asked for the password.
    2. Once in mysql, type:

      ALTER USER 'da_admin'@'localhost' IDENTIFIED BY 'daadminpass';
      GRANT ALL PRIVILEGES ON *.* TO da_admin@localhost WITH GRANT OPTION;
      FLUSH PRIVILEGES;
      quit

      That should set the password for da_admin in mysql.
  3. Now we need to make sure it's setup correctly for DA to use.   Edit /usr/local/directadmin/conf/mysql.conf and set

    user=da_admin
    passwd=daadminpass

  4. Test it out in DirectAdmin.



Some system have a /root/.my.cnf file with a preset password.  This will override the value set in DA.  If you're getting a similar error during backups or restores, try deleting or renaming your /root/.my.cnf so that it doesn't conflict.
 
Related Helpfiles
Where is my my.cnf?

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST