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原子性:整个事务中的所有操作要么全部成功执行,要么全部失败 ...
随机推荐
- SQLZOO网页中SQL的答案(SELECT from world篇)
SELECT from world篇 11. 题目: The CASE statement shown is used to substitute North America forCaribbean ...
- Mantis:Mantis rest api url 404 Not Found.解决过程纪录
测试Mantis rest api时碰到的问题:404 Not Found. 根据文件,Mantis rest api的预设url是{{url}}/api/rest/{{controller}}. 其 ...
- Jira7.10.1在Windows环境下的安装和配置
jira安装的环境准备 1. jira7.10的运行是依赖java环境的,也就是说需要安装jdk并且要是1.8以上版本: Java -version 2. 还需要为jira创建对应的数据 ...
- readfile() file_get_content f
php.ini:memory_limit memory_limit是设置内存限制的,如果使用readfile()读取文件就会和这个有关, 调用readfile()函数将打开这个文件,并且将文件内容输出 ...
- java ftp上传文件 工具类
package com.learning.spboot.utils; import com.jcraft.jsch.*; import org.apache.commons.net.ftp.FTPCl ...
- 一个http请求从用户输入网址开始到结束都发生了什么
一个http请求从用户输入网址开始到结束都发生了什么 一.一个http请求从开始到Django后台,到结束发生了什么 通过用户输入的域名解析出IP地址 TCP/IP 三次握手 进入nginx--- ...
- Python 多进程和多线程的效率对比
import time from threading import Thread from multiprocessing import Process def f1(): # time.sleep( ...
- 记一次Vue中v-model和v-bind区别
由于v-model 只是语法糖, <input v-model="message"> 与下面的两行代码是一致的: <input v-bind:value=&quo ...
- postman设置环境变量
postman属于一键式安装,不多赘述 1.设置环境变量 点击设置进入 添加环境变量 添加成功可选择 应用{{}}包住变量名即可 地址变化更换即可
- Tomcat出现 java.net.ConnectException: Connection refused 异常的原因及解决方法
原因有2. ------------------ 端口被占用 --------------------数据库链接失败导致的异常 cmd 查看 端口占用情况 检查数据库服务是否启动 --------此次 ...