Mysql Root password not working on one click application

May 25, 2016 3.8k views
One-Click Install Apps MySQL

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?

1 comment
  • 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...

2 Answers

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.

  • thanks. i dont know what happened. just deleted the droplet and created a new one and everything is now ok.

    • Thanks for reporting back. I maintain the phpmyadmin one-click and will be doing some testing of the password generation to make sure there is not an intermittent issue that we can correct on our end. If you run into any other problems feel free to post and we'll help as best as we can.

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.

Have another answer? Share your knowledge.