How can I access mysql on lamp droplet?

Posted February 25, 2014 3.1k views
I've ssh onto server. Then tried to use mysqladmin -u root -p 'password' to access mysql, but that doesn't work. How can I add a user to mysql? which command should I use?

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
4 answers
mysql -u root -p
Enter your password

CREATE USER 'username'@'host' IDENTIFIED BY 'password';
I tried it, but here is what I get:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Did you restart MySQL and set a password yet? Restart the mysql service and set a pass for MYSQL root, use that pass for mysql.
I didn't install mysql myself. I use the Lamp image when I create the Droplet.
After I login to server, actually I can't do anything on Mysql.

Especially, I was told this every time I logged in:
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

But I still can not access Mysql using the command it gives me: mysqladmin -u root -p'password' password newpassword

Do you have any idea?