Mysql Root password not working on one click application

just created phpmyadmin from one-click application install but the problem is i cant login to mysql. even after pasting the mysql password properly its giving me following error.

root@server:~# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

is there any issue on mysql root password on phpmyadmin image?


I am a new user struggling with MySql one click installations. The “Access denied…” error hapenned to me with a one-click LAMP installation, with a MySql one-click and with a Webmin one-click installation. I followed the scripts provided by DO but this is never mentioned. I am stuck here…

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

over 3 years old now, still the same issue. the supplied password does not work.

This comment has been deleted

Over a year later but I’m also running into the same problem - setup a LEMP stack and can see the root password via cat command but unable to login using it.

We haven’t seen anything reported. The method for generating this password, done when the droplet boots for the first time is pretty straightforward. We generate a random string, set the mysql root password and drop it right into the MOTD message. The code below is used:

rootmysqlpass=`tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1`
mysqladmin -u root -h localhost password $rootmysqlpass

myip=`ifconfig eth0 | grep inet | grep -v "inet6" | grep -v "" | sed 's/:/ /g' | awk '{print $3}'`

:> /etc/motd.tail

echo -ne "-------------------------------------------------------------------------------------\n" >> /etc/motd.tail
echo -ne "Thank you for using DigitalOcean's LAMP/PHPMyAdmin Application.\n" >> /etc/motd.tail
echo -ne "Your PHPMyAdmin installation can be accessed at http://$myip/phpmyadmin \n" >> /etc/motd.tail
echo -ne "The details of your PHP installation can be seen at http://$myip/info.php\n" >> /etc/motd.tail
echo -ne "Your MySQL root user's password is $rootmysqlpass\n" >> /etc/motd.tail
echo -ne "You are encouraged to run mysql_secure_installation to ready your server for production.\n" >> /etc/motd.tail
echo -ne "-------------------------------------------------------------------------------------\n" >> /etc/motd.tail
echo -ne "To delete this message of the day: rm -rf /etc/motd.tail\n" >> /etc/motd.tail

cat /etc/motd.tail > /var/run/motd.dynamic
chmod 0660 /var/run/motd.dynamic

Note that the password may contain special characters that need to be copied as well.