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

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.

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 will have to be restarted with the –skip-grant-tables option:

service mysqld stop
mysqld_safe –skip-grant-tables &

That should start up mysql without the need for a root password. Once in, type

use mysql
UPDATE user SET password=PASSWORD(‘newpass’) WHERE user=’root’;
FLUSH PRIVILEGES;
quit

That will reset the root password for you.

Type “killall -9 mysqld_safe; killall -9 mysqld” to shut down mysqld.

Start it up again with

/sbin/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. Type:

mysql -uroot -p
Then press enter. You’ll be asked for the password. Once in mysql, type:

GRANT ALL PRIVILEGES ON *.* TO da_admin@localhost IDENTIFIED BY ‘newdapass’ 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=newdapass

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.

Enable Iconv for PHP on DirectAdmin Linux Server

If you are having a Directadmin server with Apache 2 and you need to enable iconv support for php, log in as root and go to /usr/local/directadmin/customapache.

# cd /usr/local/directadmin/customapache

You should find configure.php_ap2 or configure.php files, depending on Apache version that is build using the Directadmin build system. To add iconv support we need to add the following line to these files:

–with-iconv

Then we need to go to the command line to the same directory to run our build script. The string will look like

# ./build php_ap2

If your Apache version is lower than 2, your string will be as follows:

# ./build php

It will ask you to rebuild the software you have, you don’t really need it. You won’t need to add any configure lines, the script will do this for you. Note that make and make install will be done automatically. Don’t forget to restart Apache.