mysql用户管理及授权
以mariadb5.5版本为例
新建用户
登录mariadb
# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
//创建用户
MariaDB [(none)]> insert into mysql.user(Host,User,Password) values("localhost","frank",password("frank"));
Query OK, 1 row affected, 4 warnings (0.00 sec)
//刷新系统权限表
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
这样就创建了一个名为:frank 密码为:frank 的用户。
然后登录一下。
MariaDB [(none)]>exit;
# mysql -ufrank -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
为用户授权
首先以root登录mariadb,创建一个数据库phpdb
MariaDB [(none)]> create database phpdb;
Query OK, 1 row affected (0.00 sec)
授权frank用户拥有phpdb库的所有权限
MariaDB [(none)]> grant all privileges on phpdb.* to frank@localhost identified by 'frank';
Query OK, 0 rows affected (0.00 sec)
刷新系统权限表
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
如果想指定部分权限给一用户,可以这样来写:
MariaDB [(none)]>grant select,update on phpdb.* to frank@localhost identified by 'frank';
删除用户
MariaDB [(none)]> delete from mysql.user where user="frank" and host="localhost";
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> select user from mysql.user;
+------+
| user |
+------+
| root |
| root |
| |
| root |
| |
| root |
+------+
修改指定用户密码
MariaDB [(none)]>update mysql.user set password=password('frank') where User="root" and Host="localhost";
MariaDB [(none)]>flush privileges;
mysql用户管理及授权的更多相关文章
- Mysql的用户管理与授权
Mysql用户管理 本人使用的是Mysql8.0的版本,可能会有一些语句不兼容: 1.用户管理 在Mysql中支持创建账户,并给账户分配权限:例如只拥有数据库A操作的权限.只拥有数据库B中某些表的权限 ...
- MySQL用户管理及SQL语句详解
1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysql.user; +--------+--- ...
- 【转】MySQL用户管理及SQL语句详解
[转]MySQL用户管理及SQL语句详解 1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysq ...
- MySQL用户管理、常用sql语句、MySQL数据库备份恢复
1.MySQL用户管理 给远程登陆用户授权:grant all on *.* to 'user1'@'127.0.0.1' identified by '123456' (这里的127.0.0.1是指 ...
- MySQL 用户管理与权限管理
MySQL 用户管理与权限管理 -- 操作环境mysql> show variables like 'version'; +---------------+--------+| Variabl ...
- Python 42 mysql用户管理 、pymysql模块
一:mysql用户管理 什么是mysql用户管理 mysql是一个tcp服务器,应用于操作服务器上的文件数据,接收用户端发送的指令,接收指令时需要考虑到安全问题, ATM购物车中的用户认证和mysql ...
- Mysql用户管理及权限分配
早上到公司,在服务器上Mysql的数据库里新建了个database,然后本地的系统里用原来连接Mysql账号admin连这个数据库.结果报错了,大概是这样子的: Access denied for u ...
- Linux centosVMware mysql用户管理、常用sql语句、mysql数据库备份恢复
一.mysql用户管理 grant all on *.* to 'user1'@‘127.0.0.1’ identified by 'mimA123'; 创建user1用户 使用user1登录 /us ...
- mysql事务管理和mysql用户管理
1.什么是事务? 事务是一条或者是一组语句组成一个单元,这个单元要么全部执行,要么全不执行. 2.事务特性:ACID: A:atomicity原子性:整个事务中的所有操作要么全部成功执行,要么全部失败 ...
随机推荐
- selenium多窗口切换定位
from selenium import webdriverimport unittest,time,refrom selenium.webdriver.common.keys import Keys ...
- Spring动态获取已注入的对象的方法
1.根据类获取对象 @Autowired ApplicationContext context; GenericMapper<T,String> dao=(GenericMapper< ...
- SMS PDU编码数据串格式分析
PDU协议数据单元详细介绍 PDU 相当于一个数据包,它由构成消息(SMS)的信息组成.作为一种数据单元,它必须包含源/目的地址.保护(有效)时间.数据格式.协议类型和正文,正文长度可达140字节,它 ...
- html link JS
在html中调用js代码: 一.将javascript直接写在html文件中,然后在html中调用js函数等. 二.将js代码写一个文件中,然后在html中引用该文件,在使用js文件中定义的js函数. ...
- mysql5.5.28在Linux下的安装
1. 下载mysql 在http://dev.mysql.com/downloads/mysql/ 官网上下载mysql-5.5.28-linux2.6-i686.tar.gz. 2. ...
- HTML入门标签学习
1.标题:<h1></h1>.<h2></h2>.<h3></h3>.<h4></h4>.<h5& ...
- vue项目中如何使用less
首先你的vue-cli下载完成 第一步 安装less-loader 依赖 npm install less less-loader --save-dev 直接自动就配置上了,不用手动配置 ...
- oracle mysql 比较
转载:https://www.cnblogs.com/qq765065332/p/9293029.html 一.数据的存储结构 mysql: 1.对数据的管理可以有很多个用户,登录用户后可以看到该用户 ...
- 添加PROPAGATION_REQUIRES_NEW 事务没有产生作用
最近在做事务添加时 发现自己的事务没有新建,上网查到 仅用作收藏. 其二 注意 事务的注解 应该在 内层的事务上面 一.描述Spring遇到嵌套事务时,当被嵌套的事务被定义为“PROPAG ...
- 在SQL Server 2008上安装ArcSDE 10.1并实现远程连接
先安装SQL Server 2008 R2 X64(SP2),创建数据库实例,安装客户端. 再安装ArcSDE 10.1,ArcGIS Desktop 10.1,一切顺利. 由于Desktop是32位 ...