当前位置:Gxlcms > 数据库问题 > MySQL常用操作

MySQL常用操作

时间:2021-07-01 10:21:17 帮助过:20人阅读

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

 

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

1 mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("111111"));

 

3.设置用户权限

 1 //@"%" 表示对所有非本地主机授权,不包括localhost
 2 
 3 //对localhost授权:加上一句grant all privileges on testDB.* to test@localhost identified by 111111;即可。
 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 password=password(新密码) where User="test" and Host="localhost";
2 
3  mysql>flush privileges;

 

5.

 

MySQL常用操作

标签:mysql常用操作   source   电脑   系统   int   value   nbsp   主机   password   

人气教程排行