MySQL Root Password

I have successfully installed apache+php+mysql on my linode, however I am a little unsure has to how to change the root password for the SQL server (or add other accounts for that matter).

Does anybody have any insight?

4 Replies

Simple answer: shell_prompt> mysql -u root mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('new_password'); mysql> SET PASSWORD FOR ''@'my_host_name' = PASSWORD('newpassword');
Check here - ~~[" target="blank">]( … leges.html">]( - for the definitive answer.

Before you set the passwords, you need to have run the setup program (mysqlinstalldb) to build and initialse the grant tables Some distros (notably RedHat) run mysqlinstalldb during the install, some leave it to you to do it later (for example - Gentoo). Guidance here - ~~[" target="blank">]( … ation.html">](

It's not working for some reason. I keep getting:

> /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user: 'root@localhost' (Using password: YES)'

Any ideas?

Edit: Oh yes, that's using the command:
> /usr/local/mysql/bin/mysqladmin -u root password new_password

Looks like it's trying to use a password even though you have not specified the '-p' option. You cound have a password set in /etc/my.cnf or ~/.my.cnf (or whatever it is on your system).


shell_prompt> mysql -u root -p

But just press [return] at the password prompt.

Thanks buddy, good thinking :-)


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct