Printable Version of Topic
Click here to view this topic in its original format
Dingetje's Forum > Tips & Tricks > reset mySQL root password


Posted by: dingetje Oct 21 2003, 03:42 PM
if you get an error like:

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

when you try to gain access to mySQL database (either via mysql or mysqladmin) and you cannot remember what your mySQL password was for user 'root' then follow this procedure to set the password to a known value:

QUOTE
[Linux] rc_mySQL stop
[Linux] fork /path/to/safe_mysqld --skip-grant-tables
[Linux] mysql -uroot mysql
mysql> update user set password=PASSWORD('your_new_password') where user='root';
Query OK, 2 rows affected (0.13 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye
[Linux] rc_mySQL restart


for FREESCO 03x /path/to = /usr/local/mySQL/bin
for FREESCO 027 /path/to = /mnt/router/packages/mySQL/bin

your_new_password can also be empty:

QUOTE
mysql> update user set password=PASSWORD('') where user='root';


based on http://www.mysql.com/doc/en/Resetting_permissions.html

Posted by: phbc50 Sep 18 2005, 05:51 AM
Hello,
For mysql-4.1.7a-lightning, the safe_mysqld is replaced by mysqld_safe
So use
CODE
fork /path/to/mysqld_safe --skip-grant-tables

instead of
CODE
fork /path/to/safe_mysqld --skip-grant-tables

in the howto above.
Remark :
with this package : /path/to = /usr/local/mysql/bin (all lower case).

phbc50

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)