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)
root@server:~#

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…

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.

×
3 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:

mysql_install_db
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 "127.0.0.1" | 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.

  • On a new installation, if you’re not running the following commands as the root user:

    • mysql_secure_installation
    • mysql -uroot -p

    then you’ll receive the “Access Denied” error.

    The command sudo su will allow you switch from your current user to the root user (assuming your current user as root privileges) on the CLI. Once you do that, you can run the above commands as expected.

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

Submit an Answer