[root@alanstudio]# mysql -uroot -p login mysql with user 'root'[root@alanstudio]# mysqladmin -uroot password 123456 First time set password, without -p [root@alanstudio]# mysqldump -uroot -p databasename > databasename.sql [root@alanstudio]# mysql -uroot -p databasename < databasename.sql Restore database to backup file .sql[root@alanstudio]# cp -fr /var/lib/mysql /home/backup Backup whole mysql and database directory[root@alanstudio]# mysql -D databasename -uroot -p123456 -e 'show tables;' mysql> show databases; show all databases in mysqlmysql> use databasename; use(logon to) specific database in mysqlmysql> drop database databasename; delete database in mysqlmysql> show tables; show all tables in one of database in mysqlmysql> select * from tablename; show all record in specific table in mysqlmysql> source xxx.sql; use the xxx.sql source scriptmysql> show columns from tablename; show columns in specific table in mysqlmysql> desc tablename; show the format/description of table in mysqlmysql> INSERT INTO tablename VALUES('field1','field2',field3'); INsert new row record into table in mysqlmysql> update tablename set city='hk' where id='3' and city='tw'; update record in specific table in mysqlmysql> update tablename set password=encrypt('123456') where name='alan; update encrypt password record in specific table in mysqlmysql> delete from tablename where name='alan' and city='hk' and id='5'; delete one row record in specific table in mysqlmysql> use mysql; mysql> select host,user,password from user; use default mysql database and query the information of table 'user' in mysqlmysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED by 'password'; mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED by 'password'; grant the all privileges in all databases for user 'root' and allow other server/pc to access the server's mysqlmysql> GRANT ALL PRIVILEGES ON db.* TO user@'%' IDENTIFIED by 'password'; mysqlbinlog -v --base64-output=decode-rows --read-from-remote-server -uroot -pPassWord -h192.168.1.100 mysql-bin.001234 > mysql-bin.001234.log To convert base64 binary log to plain textServer is hosted by Alanstudio Linux Operating System Recommend screen resolution 1024 x 768 / IE / FireFox Alan Studio © 2007 by Alan Cheung Hin Lun. All rights reserved. |