Como resetear la contrasena del servidor mysql

Imagen de RazaMetaL

Este sencillo tip nos permitira cambiar la contrasena de root para el demonio mysql, el procedimiento es como se lista a continuacion:

1.- Detenemos mysql

/etc/init.d/mysqld stop

Un killall tambien nos sirve:

killall mysqld

2.- Ejecutamos :

/usr/libexec/mysqld --skip-grant-tables --user=root &

3.- Ingresamos con el cliente mysql a la base de datos mysql:

mysql mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE mysql.user SET Password=PASSWORD('aquivalaclavenueva')
-> WHERE User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

[root@sip share]# killall mysqld

4.- Finalmente reiniciamos el servicio:


/etc/init.d/mysqld start

Eso es todo.. ahora a probar si funciona :)

mysql -u root -paquivalaclavenueva
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>