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 - ~~[http://dev.mysql.com/doc/mysql/en/Defaultprivileges.html" target="blank">](http://dev.mysql.com/doc/mysql/en/Defau … leges.html">http://dev.mysql.com/doc/mysql/en/Default_privileges.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 - ~~[http://dev.mysql.com/doc/mysql/en/Unixpost-installation.html" target="blank">](http://dev.mysql.com/doc/mysql/en/Unix_ … ation.html">http://dev.mysql.com/doc/mysql/en/Unix_post-installation.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).

Try:

shell_prompt> mysql -u root -p

But just press [return] at the password prompt.

Thanks buddy, good thinking :-)

Reply

Please enter an answer
Tips:

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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct