Code : Tout sélectionner
$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Code : Tout sélectionner
root@ toto:~#/etc/init.d/mysql stop
Pour ce faire¹.
Code : Tout sélectionner
:~# mysqld_safe --skip-grant-tables &
[1] 15840
root@ toto:~# 111020 16:20:21 mysqld_safe Logging to syslog.
111020 16:20:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
- ATTENTION : dès lors, vos bases de données sont accessibles depuis l'extérieur, À TOUTES et TOUS, à partir de ce moment !

Cette dernière¹ étant lancée, la console reste en attente.
On se connecte au serveur mysql en tant que root (mysql).
Code : Tout sélectionner
mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.49-3 (Debian)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Code : Tout sélectionner
mysql> 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
mysql>
Code : Tout sélectionner
mysql> select host,user,password from user;
+---------------------+------------------+-------------------------------------------+
| host | user | password |
+---------------------+------------------+-------------------------------------------+
| localhost | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
toto.com | root | |
| 127.0.0.1 | root | |
| localhost | debian-sys-maint | *yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy |
+---------------------+------------------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
- Remplacer UNIQUEMENT les caractères XXXXXX[...]XXXXXXX
Code : Tout sélectionner
mysql> update user set password=PASSWORD("XXXXXX[...]XXXXXXX") where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>
Code : Tout sélectionner
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
Code : Tout sélectionner
mysql> quit;
Bye
root@toto:~#
Code : Tout sélectionner
root@ toto:~# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld111020 16:37:52 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
.
[1]+ Done mysqld_safe --skip-grant-tables
root@ toto:~#
Code : Tout sélectionner
root@ toto:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
root@toto:~#
PS : mysql> help
