mysql

lvm    
查看昨天负载情况    
iostat 相关的    
查看当前静态内存使用百分比    
日志类型    
当前登入用户    
last |sort -r    
cmake  mysql5.1 5.5    
mysql  基本操作  导入导出表,表结构

show status;    
show engines; 
show variables like '%engine%'; #查看当前库的engine    
show processlist;    
mysql -u root -h localhsot -p    
mysqldump -u root -p --databases cacti > /opt/db.sql  #导出数据库    
mysql --all-databases > all-databases.sql #导出整个数据库    
mysql < db.sql    
mysqldump -u root -p cacti > /opt/cactibak.sql  #导出整个数据库中的所有表    
mysqldump -u root -p cacti user_auth tables2 > /opt/ser.sql  #导出某张表    
a.)mysql -u root -p cacti < /opt/cactibak.sql   #导入表到数据库    
b.)    
  mysql>use cacti;    
  mysql>source /opt/cactibak.sql    
  mysql>

update tablename set rowname=value where  rowname1="127.0.0.1";

grant all on *.* to cacti@"%" identified by 'redhat';   #增加用户的方法啊!!!    
all : insert update  delete select    
create user username identified by ‘redhat’;

revoke all privileges on *.* from root@"%";   #删除授权    
delete from user where user="rot" and host="%";    
alter table t1 rename t2;  #重命表名

describe table 表名;  == desc table 表名;  == show columns from 表名;    
show create table 表名;  #查看表详细结构语句    
ALTER TABLE user MODIFY name VARCHAR(30);    
ALTER TABLE 表名 ADD 属性名 1 数据类型 [完整性约束] [FIRST|AFTER 属性名 2];    
ALTER TABLE 表名 DROP 属性名;    
ALTER TABLES  user ENGINE=MYISAM|INNODB|MEMORY;  #更改表的存储引擎。    
DROP INDEX 索引名 ON 表名;


创建表三种方法:

  1. CREATE TABLE test;

  2. CREATE TABLE datatest SELECT * FROM test;   #创建复制数据,但不复制表结构

  3. CREATE TABLE like test;   #复制表结构,数据为空


修改表:

  1.  ALTER TABLE test ADD UNIQUE KEY (Couse);

  2. ALTER TABLE test ENGINE=Innodb;   #修改表引擎

  3. ALTER TABLE test CHANGE Couse Course VARCHAR(50) NOT NULL;

  4. ALTER TABLE test RENAME TO  test1;  ==   RENAME TABLE test TO test1;

  5. CREATE INDEX name_on_student ON student (Name(5) DESC|ASC) USING BTREE;  #创建索引

  6. DROP INDEX  name_on_student ON student;  #删除表索引

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章