转载地址:http://blog.csdn.net/china_skag/article/details/6921335
MySql命令:
    SHOW VARIABLES LIKE 'server_id'          

   SHOW DATABASES                                //列出 MySQL Server 数据库。  
     SHOW TABLES [FROM db_name]                    //列出数据库数据表。  
     SHOW TABLE STATUS [FROM db_name]              //列出数据表及表状态信息。  
    SHOW CREATE TABLE tbl_name;            //显示表信息。

    SHOW COLUMNS FROM tbl_name [FROM db_name]     //列出资料表字段  
    SHOW FIELDS FROM tbl_name [FROM db_name],DESCRIBE tbl_name [col_name]。  
    SHOW FULL COLUMNS FROM tbl_name [FROM db_name]//列出字段及详情  
    SHOW FULL FIELDS FROM tbl_name [FROM db_name] //列出字段完整属性  
    SHOW INDEX FROM tbl_name [FROM db_name]       //列出表索引。  
    SHOW STATUS                                  //列出 DB Server 状态。  
    SHOW VARIABLES                               //列出 MySQL 系统环境变量。  
    SHOW PROCESSLIST                             //列出执行命令。  
    SHOW GRANTS FOR user                         //列出某用户权限
    show variables like ‘port’;            //查看端口号
    status;                        //显示mysql信息
---------------------------------------------------------------------------------------------------
    alter database order_movie_ticket character set gbk;  //修改数据库编码
    alter table tableName engine=InnoDB;       //修改数据表类型,如果有索引需要先移除
    alter table tableName engine=MyISAM;
    ALTER TABLE 表格名 DROP INDEX 索引名;      //移除索引
    alter table tbl_name default character set utf8 collate utf8_bin;//修改表编码类型

---------------------------------------------------------------------------------------------------
    insert into table1 (field1,field12) values ('value1',11);  //新增
    
insert into B(5,6,7,8) select 1,2,3,4 from A;

---------------------------------------------------------------------------------------------------
  load data local infile 'd:\\s.txt' into table test character set utf8(timestamp,lastyear,thisyear,ratio);  //导入数据文件-编码格式utf8
  load data local infile 'd:\\s.txt' into table test fields terminated by ';';
  INSERT gateway(piserverip,timestamp) values ('192.168.118.151','1988.02.03 19:54:55') ON DUPLICATE KEY UPDATE timestamp='1988.02.03 19:54:55';

---------------------------------------------------------------------------------------------------
    select version();                 //查询版本
---------------------------------------------------------------------------------------------------
 

    update mysql.user set password=password('123456') where User='test1' and Host='localhost';//修改密码

---------------------------------------------------------------------------------------------------
    delete from user where user='test2' and host='localhost'  //删除用户
---------------------------------------------------------------------------------------------------

    drop database 数据库名;  //删除数据库

    drop table 表名;      //删除表

     drop user 用户名@'%'    //删除账户及权限

     drop user 用户名@localhost //删除账户及权限

 

---------------------------------------------------------------------------------------------------

      FROM_UNIXTIME(1346812200,'%Y-%m-%d %H:%i:%s');  //时间戳转日期

    flush tables with read lock;  //锁定表

    unlock tables;        //解锁表

 

-------My.ini--------------------------------------------------------------------------------------------
   tmp_table_size=         //修改内存表大小
   set @max_heap_table_size=#
   show variables like '%tmp_table_size%';
   show variables like '%max_heap_table_size%';  //

    



常见错误信息:
  ERROR 1366 (HY000) //中文显示问题
    解决方案
  ERROR 1044 (42000) //权限问题
    grant select,insert,update,delete on wotdb.* to wotuser@192.168.1.128 identified by "wotpwd";  //权限修改
    grant all privileges on *.* to root@"%" identified by 'rootpwd';  //权限修改
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
    /etc/init.d/mysql stop   (service mysqld stop )
    /usr/bin/mysqld_safe --skip-grant-tables
  ERROR 1146 (42S02): Table 't.test' doesn't exist 
    ibdata1与数据库文件对不上号的原因

---------------------------------------------------------------------------------------------
解锁
mysqladmin flush-hosts -uroot -prootpwd -P3307 -h192.168.118.22

---------------------------------------------------------------------------------------------

mysql设置int类型主键自增长,以指定从1000开始为例。

 

1 创建表的时候就设置: 

 

CREATE TABLE `Test` (                                                                                 

          `ID` int(11) NOT NULL AUTO_INCREMENT,                                                               

          `class` varchar(2) NOT NULL,                                                                        

          `NAME` varchar(50) NOT NULL,                                                                         

          `SEX` varchar(2) NOT NULL,                                                                          

          PRIMARY KEY (`ID`)                                                                     

        ) ENGINE=MEMORY AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC

 

2 如果在创建表时没有设置,后来想设置,可以通过修改实现:

 

alter   table   Test   auto_increment   =   1000;


    



posted on 2012-07-02 16:16  双面煎蛋  阅读(1141)  评论(0编辑  收藏  举报