divendres, 17 de gener de 2014

Change Passwords for MySQL Users

Cambiar el password d'un usuari ja creat de MySQL es molt fàcil només hem d'utilitzar les segûents comandes:
root@db [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
root@db [mysql]> \P less
PAGER set to 'less'
root@db [mysql]> select * from user where user='user'\G;
1 row in set (0.01 sec)

ERROR:
No query specified

root@db [mysql]> SET PASSWORD FOR 'user'@'localhost' = PASSWORD('Pass');
Query OK, 0 rows affected (0.04 sec)

root@db [mysql]> SET PASSWORD FOR 'user'@'%' = PASSWORD('Pass');
Query OK, 0 rows affected (0.04 sec)


root@db [mysql]> select * from user where user='user'\G;
1 row in set (0.00 sec)
Una volta el select ens mostra tots els usuaris busquem l'usuari que vulguem cambiar i llancem la comanda SET.

El '%' indica que es pot accedir desde qualsevol IP.