MySQL notes

Make backup of database "khmel" on Linux:

mysqldump -u root -p khmel > /home/khmel/phn-2010.12.15.sql


Recovery to database "khmel" on Windows:

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql.exe -u root -p khmel < c:\khmel-2010.12.15.sql

Set root password after install:

# mysqladmin -u root password NEWPASSWORD

Change password:

mysqladmin -u root -p OLD_PASSWORD password NEW_PASSWORD

Change password for some user: mysql> use mysql;

mysql> update user set password=PASSWORD("NEW_PASSWORD") where User='khmel';
mysql> flush privileges;

Reset root password:

service mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD('NEW_PASSWORD') where User='root';
Query OK, 0 rows affected (0.01 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select user from user;
Empty set (0.00 sec)
mysql> SELECT User, Host, Password FROM mysql.user;
Empty set (0.00 sec)