MySQL root password

February 25, 2013 141.8k 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
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.

@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?
@rekcahx: Log in to your droplet and read the MOTD. The MySQL password is there.
Lee Reinhardt's Answer. Work for me.
Jeez. Why isnt the 'password' thing in the docs. fiddled so much to find it.
I've changed my mysql password but the warning still shows up in motd. Anyone know how to clear that?
@jstark: Simply empty out the /etc/motd.tail file.
Please explain "Log in to your droplet and read the MOTD. The MySQL password is there. "

If I ssh into the server and login the message does not provide the mysql password. How do I "read" the message of the day?
@layne.heiny: Are you using the LAMP one-click image? If not, the password won't be in the MOTD.

If you forgot your mysql root password, check out www.cyberciti.biz/tips/recover-mysql-root-password.html.
Your MySQL root password is in /root/.my.cnf and it is different for every droplet, as it is randomly generated for every droplet.
It's all detailed in the manual here: https://www.digitalocean.com/community/articles/one-click-install-wordpress-on-ubuntu-12-10-with-digitalocean
My default mysql root password is blank. You need to set password with below command.
mysqladmin password password


what is an MOTD?
  • Message Of The Day - it appears at the top of your console screen when you log into your console.

never mind i figured that out.... but what i cant get is when I run mysql with no args i am granted accesss, when i enter "mysql -u root" i get access, when I enter "mysql -u root -p" and enter no password or the password "password", no access. I tried to install phpmyadmin because i am trying to mysqldump the entire WP data to an sql file to play with some woocommerce order info for email scripting, but i am having trouble with this. in my MOTD i don't see anything regarding a default mysql password that I should change.
  • The image was updated and the root password is no longer "password". You can find your MySQL root password in /root/.my.cnf, you can also run this command to extract it from the file:

    tail -1 /root/.my.cnf | awk -F'=' '{print $2}'
    

If you're using a Wordpress image and logged in as root, you can find the MySQL root password with this command:

cat ~/.my.cnf

@kamaln7 and @payetteforward 's answer is right for me. Thanks so much.

To get the Default MySQL password for pre-installed LAMP (Ubuntu 14 image)

On root console execute following command
reload SSH

Have another answer? Share your knowledge.