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 表名;
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