Monday, 4 May 2009

Useful mysql

Some mysql commands that can be useful from time to time:

1. Recovering root password
/etc/init.d/mysql stop

mysqld_safe --skip-grant-tables &

mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

/etc/init.d/mysql stop

/etc/init.d/mysql start

2. Adding database and creating user
mysql> CREATE DATABASE db_name;
mysql> USE DATABASE db_name;
mysql> GRANT ALL ON *.* TO 'user'@'localhost' IDENTIFIED BY 'pass1';
mysql> GRANT ALL ON db_name TO 'user'@'localhost' IDENTIFIED BY 'pass1';

Thats all for now..

No comments:

Post a Comment