您的位置:首页 > 数据库 > MySQL

mysql 常用语句

2009-10-13 15:27 375 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: