Setting root password on mysql 5.4
Michael Powell
nightrecon at hotmail.com
Sun Jan 10 03:41:43 UTC 2010
jaymax wrote:
>
> Does anyone know how to set root password on a new mysql installation from
> the post?
This is the very first thing performed on a brand new fresh install.
The canonical procedure (and I haven't had to do it in a while so it is
possible it may have changed) looks something like this:
As root at a '#' prompt do: mysql --user=root mysql
This brings up the mysql prompt:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' [press return or
enter]
at the -> prompt type in the following command:
IDENTIFIED BY '' WITH GRANT OPTION; [press return or enter]
The above should exit back the mysql> prompt if all went well. This will
allow root to login with no password, but only on localhost. If you wish to
expand this for the same from any host execute the steps again with the
below differences. Otherwise type quit at the mysql> prompt to exit. The
main reason the second step may be desirable is to admin from a different
box using the MySQLAdminGUI for example. Be warned however!: If this box is
accessible by anyone from anywhere it is a security hole as root has NOT yet
been assigned a password! And this procedure does NOT assign any password,
it only sets the access so you can.
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' [press return or enter]
at the -> prompt type in the following command:
IDENTIFIED BY '' WITH GRANT OPTION; [press return or enter]
Next at mysql> prompt just type quit to exit.
Restart mysql and now root can login with no password. Either use the
command line to set the password, or the MySQLAdminGUI in the USERS section.
The GUI is simple but I'll leave as an exercise for you to look up the CLI
procedure in the MySQL docs should you get this far. You need to follow the
above procedure first before you can log in as root in order to change the
password.
To reiterate: the above does NOT assign a password, it only allows root
initial access so he can then set a password. Check out:
http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html
http://dev.mysql.com/doc/refman/5.1/en/user-account-management.html
> Can it be performed after starting the server with
> /usr/local/bin/mysqld_safe &
>
> Or for that matter with
> /usr/local/bin/mysql_secure_installation
>
Sorry but these two are not something I'm really familiar with. If the
canonical approach doesn't work, maybe you can try to temporarily start it
with neither of these in the mix, set the password, then restart it with
these two active again.
-Mike
More information about the freebsd-questions
mailing list