Mysql 用户添加、密码修改、授权等
2016-04-29 16:15
465 查看
一、数据库的连接
1:连接本地数据库(root 用户,隐藏密码)
mysql -u root -p
2:连接本地数据库(root用户,密码为123,与-p不能有空格)
mysql -u root -p123
3:远程连接数据库(IP为192.168.7.116,用户为ll)
mysql -h 192.168.7.116 -P 3306 -u ll -p
4:连接指定的数据库Test(登陆进去可直接用select database()查看)
mysql -u root -p123 -D Test
二、密码的修改
1:在没有密码的情况下
mysqladmin -u root password
2:修改密码(在知道原密码的情况下)
mysqladmin -u root -p password 123
3:在mysql.user表里修改(重启mysql服务或flush privileges才生效,password设置的时候不能直接password='13')
update mysql.user set password=password('123456') where user='root' and host='localhost';
4:在mysql里修改:
set password for ll=password('123456');
5:忘记密码
打开配置文件 vim /etc/my.cnf 在里面添加 skip-grant-tables
三、用户添加与授权
1:create添加用户
create user ll identified by '123456';
2:修改用户名
rename user ll to lll;
3:在mysql的user表中直接添加用户信息
insert into mysql.user(User,Host,Password) values('ll','localhost',password('123'));
3: grant授权方式添加用户
grant select,insert on lop.* to 'mm'@'localhost' identified by '123';
若密码修改为空
grant select,insert on lop.* to 'mm'@'localhost' identified by '';
4:查看用户的权限
show grants ; show grants for ll;
5:权限的收回
revoke select,insert on lop.* from 'mm'@'localhost';
四、删除用户
1:在mysql的user表中删除
delete from mysql.user where user='ll';
drop user 'll'@'localhost'
1:连接本地数据库(root 用户,隐藏密码)
mysql -u root -p
2:连接本地数据库(root用户,密码为123,与-p不能有空格)
mysql -u root -p123
3:远程连接数据库(IP为192.168.7.116,用户为ll)
mysql -h 192.168.7.116 -P 3306 -u ll -p
4:连接指定的数据库Test(登陆进去可直接用select database()查看)
mysql -u root -p123 -D Test
二、密码的修改
1:在没有密码的情况下
mysqladmin -u root password
2:修改密码(在知道原密码的情况下)
mysqladmin -u root -p password 123
3:在mysql.user表里修改(重启mysql服务或flush privileges才生效,password设置的时候不能直接password='13')
update mysql.user set password=password('123456') where user='root' and host='localhost';
4:在mysql里修改:
set password for ll=password('123456');
5:忘记密码
打开配置文件 vim /etc/my.cnf 在里面添加 skip-grant-tables
三、用户添加与授权
1:create添加用户
create user ll identified by '123456';
2:修改用户名
rename user ll to lll;
3:在mysql的user表中直接添加用户信息
insert into mysql.user(User,Host,Password) values('ll','localhost',password('123'));
3: grant授权方式添加用户
grant select,insert on lop.* to 'mm'@'localhost' identified by '123';
若密码修改为空
grant select,insert on lop.* to 'mm'@'localhost' identified by '';
4:查看用户的权限
show grants ; show grants for ll;
5:权限的收回
revoke select,insert on lop.* from 'mm'@'localhost';
四、删除用户
1:在mysql的user表中删除
delete from mysql.user where user='ll';
drop user 'll'@'localhost'
相关文章推荐
- mysql参考
- mysql 5.5多实例部署
- centOS 7 安装nodeJs & mysql 常见问题
- mysql安全修改mysql数据库名几种方法
- MySQL数据库迁移(数据文件直接迁移)
- 【MySQL】查询保持IN中的顺序
- Mysql接口大全
- Windows Server 2003 mysql主从同步
- Vitess首页、文档和下载 - 分布式MySQL工具集 - 开源中国社区
- MySql创建视图
- mySQL笔记2
- MySQL触发器使用详解
- mySQL笔记1
- MySQL触发器使用详解
- MySQL触发器使用详解
- mysql的学习笔记
- 写MySQL存储过程实现动态执行SQL
- mysql递归层次查询
- MySQL的log-bin的日志功能
- mysql trace