MySQL常用操作

1.导入数据库

1 use 数据库;
2 source 路径/文件名;

 

2.新建用户,此处的"localhost",是指该用户只能在本地登录,如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。也可以指定某台机器可以远程登录。

1 mysql> GRANT USAGE ON *.* TO 'test'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;

 

3.设置用户权限

 1 //@"%" 表示对所有非本地主机授权,不包括localhost
 2 
 3 //对localhost授权:加上一句即可。
 4 
 5 //testDB的所有权限
 6 mysql>grant all privileges on testDB.* to test@localhost identified by '111111';
 7 
 8 //testDB的部分权限
 9 mysql>grant select,update on testDB.* to test@localhost identified by '111111';
10 
11 //test用户对所有数据库都有select,delete,update,create,drop 权限。
12 mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "111111";
13 
14 //刷新系统权限表
15 mysql>flush privileges;

 

4.修改指定用户密码

1 mysql>update mysql.user set authentication_string=password('新密码') where User="test" and Host="localhost";
2 
3  mysql>flush privileges;

 

5.Win10环境变量,在Path下新建,路径指向bin

 

6.如果想从外网访问,找到mysql.cnf(这个文件有很多个,慢慢找)注释掉bind-address = 127.0.0.1,然后重启

 

7.设置自增id的起始值

alter table table_name AUTO_INCREMENT=10000;

 

posted @ 2017-05-09 19:54  火热火热7  阅读(133)  评论(0)    收藏  举报