Đăng nhập

My MySQL commands

To start, stop, restart mysql server:

$ /etc/init.d/mysqld start
$ /etc/init.d/mysqld stop
$ /etc/init.d/mysqld restart
$ /etc/init.d/mysql start
$ /etc/init.d/mysql stop
$ /etc/init.d/mysql restart

Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:

# service mysqld start
# service mysqld stop
# service mysqld restart

Setup a password for root user & Login:

# mysqladmin -u root password NEWPASSWORD
mysql> update user set password=password('qazwsx') where user='root';
# mysql -u root -p

Export and Import Dump:

# mysqldump -u "your_username" -p --lock-tables "your_database" > your_database_dump.sql
# mysqldump -u "your_username" -p --lock-tables --databases DB1 [DB2 DB3...] > your_database_dump.sql
# mysqldump -u "your_username" -p --lock-tables --all-databases > your_database_dump.sql
# mysql -u "your username" -p "your_database" < database_dump.sql
# mysql -u "your_username" -p < your_database_dump.sql

Privilege:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'msentissi'@'192.168.3.10' identified by 'yourpassword' ;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TEMPORARY TABLES ON tn_oto_dev.* TO 'oto_tn_dev'@'%'
mysql> Flush Privileges;
mysql> SHOW GRANTS FOR 'root'@'localhost';
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';