Command
#查看版本MySQL--version
#进入mysql CommandMysql-u root-pmysql-u [email protected] (case without password)
#创建数据库Create DATABASE [dataname] #删除数据库drop database [dataname] #查看数据库show databases; #进入具体数据库use [dataname] #查看数据库表show tables; #删除表drop table [tablename] #查看具体表的结构desc [tablename] #查找数据select * FROM tablename #插入数据insert Insto [TableName] (103, ' test ‘); #修改数据update [TableName] set name= "and id=103 #删除数据delete [tablename] where name= ' #添加索引
ALTER TABLE [tablename] Add fulltext index ([ColumnName]);
#查看索引
Show index from [tablename] \gStart switch: Service MySQL {start|stop|status|restart|condrestart|try-restart|reload|force-reload}
Repair Table
View table Status
Show Table status like ' tablename ' \g;Inspection table
Check Table tablenameRepair table
Repair Table TableName
Compression Table
View data File Locations
show global variables like '%datadir% ';
Compress Files
Myisampack *. MYD
#mysql Backup
Cold Backup
BackupStop MySQL service, restart MySQL service in Operation Basic backup MySQL database, backup restart after production Binlog
Logical RecoveryMysql-u Root-p [Databasename]<[backname].sql
Logical BackupExport entire Database mysqldump-u root-p [DatabaseName]-F >[backname].sql export a table mysqldump-u root-p [DatabaseName] [tablename]>[ Table].sql Export Database Structure mysqldump-u root-p-D--add-drop-table [Databasename]>[database].sql- D No data--add-drop-table add a drop table before each create statement
Linux MySQL Base operation