Question

MySQL root password

Posted February 25, 2013 198.2k views
Hi, I just created a new droplet and used the "LAMP on Ubuntu 12.04" application to set it all up and have LAMP installed automatically. Works great, but when I want to install phpmyadmin, it asks for the MySQL password. I tried several options like "root" or empty, but it doesn't work. Where can I find the password for MySQL? Thanks!
6 comments

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.

×
Submit an Answer
25 answers

When you install a LAMP droplet in digitalOcean
this is the code to get your mysql password
cat /root/.digitalocean_password

Log in and like this answer so that it can get to the top

If you installed LAMP ubuntu or whatever flavour of Linux that just cat the motd message to find the password (why put it here i wonder?????)
root@domain:/var/www# cat /etc/motd.tail
-------------------------------------------------------------------------------------
Thank you for using DigitalOcean's LAMP Application.
Your web root is located at /var/www/html and can be seen from http://xxx.xxx.xxx.xxx/
The details of your PHP installation can be seen at http://xxx.xxx.xxx.xxx/info.php
Your MySQL root user's password is XXXXXXXXXX
You are encouraged to run mysql_secure_installation to ready your server for production.
-------------------------------------------------------------------------------------
To delete this message of the day: rm -rf /etc/motd.tail

STOP all and read >> If you installed LAMP ubuntu or whatever flavour of Linux that just cat the motd message to find the password (why put it here i wonder?????) root@domain:/var/www# cat /etc/motd.tail

When you install MySQL often it will ask you to set a root password which you may have set and forgotten.

You can test access directly by doing:
# mysql -u root

To see if the root user has no password set, if it doesn't work then it means one is set.

You can restart mysql with skip grant privileges which will remove any auth and then login and reset the password though it may be just easier to reinstall MySQL if you haven't setup any databases yet.
@rekcahx: Log in to your droplet and read the MOTD. The MySQL password is there.

@razalghul is Awesome :)

Easier to just reset it. Try this:

service mysql stop
echo "UPDATE mysql.user SET Password = PASSWORD('mypassword') WHERE User = 'root';" > ~/mysql-reset.sql
echo "FLUSH PRIVILEGES;" >> ~/mysql-reset.sql
chown mysql:mysql ~/mysql-reset.sql
mysqld_safe --init-file=~/mysql-reset.sql &
rm ~/mysql-reset.sql
# confirm it works
mysql --user=root --password=mypassword
> quit;
service mysql stop
service mysql start
I appreciate the answers on how to reset a password if it is lost, but this shouldn't be required every time a new droplet is created using the Ubuntu LAMP app image. There appears to be a password set, but I have found no documentation on what DO sets it to.
Wow, my bad. I just noticed the MOTD when logging in says:

Please be sure to change your root MySQL password; current MySQL password is "password"
You can change the MySQL password with the following command:
mysqladmin -u root -p'password' password newpassword

Should probably still put it in the docs somewhere.
Answer was still not posted.

How do you find out your mysql password?
Previous 1 2 3 Next