mysql 常用语句

1.添加用户
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush   privileges; 


2.远程连接
use   mysql; 
update   user   set   host='%'   where   user='root';

 

3. 

mysql -u root mysql
mysql> UPDATE user SET Password = PASSWORD('newpwd')   
       ->     WHERE User = 'root';
mysql> FLUSH PRIVILEGES;    //需要此句生效
 

 4.

建立索引:
mysql>alter table 表名 add index (字段);
mysql>alter table 表名 add primary key (字段);
mysql> show columns from 表名;
刪除索引:
mysql>alter table 表名 drop index 字段;
mysql>alter table 表名 drop primary key 字段;
mysql>show columns from 表名;
 
5.备份
  mysql\bin>mysqldump -u root -proot orapp > back.sql
 
 

posted on 2009-10-13 15:27  alon  阅读(156)  评论(0编辑  收藏  举报

导航