Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have need to connect to mySql server 5.5 and create database using command line. Ideally it would be using a UI utility but I don't have it. Here is an issue:

alex@ubuntu:~$ sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

However I definitely set password while I was installing MySql server.

What should I do to solve it?

share|improve this question
up vote 2 down vote accepted

Connect with sudo mysql -u root -p and it will prompt you for the password. The key here is the -p option. You can also provide the password as part of the command with the -p option, but that is considered a security risk, since the password will be stored in clear text in your commands history.

share|improve this answer
" since the password will be stored in clear text in your commands history". Not if you start with a space. It WILL show up in your process list too though so it is still unwise to do so. – Rinzwind Jul 29 '12 at 17:30
Can you explain what you mean by "start with a space"? – Marios Zindilis Jul 29 '12 at 17:32
yes sir. Commands that start with a space do not end up in history. mysql -u user -p vs. {space}mysql -u user -p – Rinzwind Jul 29 '12 at 17:36
Interesting feature! Does not work in Fedora/Red Hat family. – Marios Zindilis Jul 29 '12 at 17:50

Also; if you need a GUI, you may use either Webmin available from or MySQL workbench available at

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.