以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用户管理及授权的更多相关文章

  1. Mysql的用户管理与授权

    Mysql用户管理 本人使用的是Mysql8.0的版本,可能会有一些语句不兼容: 1.用户管理 在Mysql中支持创建账户,并给账户分配权限:例如只拥有数据库A操作的权限.只拥有数据库B中某些表的权限 ...

  2. MySQL用户管理及SQL语句详解

    1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysql.user; +--------+--- ...

  3. 【转】MySQL用户管理及SQL语句详解

    [转]MySQL用户管理及SQL语句详解 1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysq ...

  4. MySQL用户管理、常用sql语句、MySQL数据库备份恢复

    1.MySQL用户管理 给远程登陆用户授权:grant all on *.* to 'user1'@'127.0.0.1' identified by '123456' (这里的127.0.0.1是指 ...

  5. MySQL 用户管理与权限管理

    MySQL 用户管理与权限管理 -- 操作环境mysql> show variables like 'version';  +---------------+--------+| Variabl ...

  6. Python 42 mysql用户管理 、pymysql模块

    一:mysql用户管理 什么是mysql用户管理 mysql是一个tcp服务器,应用于操作服务器上的文件数据,接收用户端发送的指令,接收指令时需要考虑到安全问题, ATM购物车中的用户认证和mysql ...

  7. Mysql用户管理及权限分配

    早上到公司,在服务器上Mysql的数据库里新建了个database,然后本地的系统里用原来连接Mysql账号admin连这个数据库.结果报错了,大概是这样子的: Access denied for u ...

  8. Linux centosVMware mysql用户管理、常用sql语句、mysql数据库备份恢复

    一.mysql用户管理 grant all on *.* to 'user1'@‘127.0.0.1’ identified by 'mimA123'; 创建user1用户 使用user1登录 /us ...

  9. mysql事务管理和mysql用户管理

    1.什么是事务? 事务是一条或者是一组语句组成一个单元,这个单元要么全部执行,要么全不执行. 2.事务特性:ACID: A:atomicity原子性:整个事务中的所有操作要么全部成功执行,要么全部失败 ...

随机推荐

  1. Where do I belong (freeCodeCamp)

    先给数组排序,然后找到指定的值在数组的位置,最后返回位置对应的索引. 举例:where([1,2,3,4], 1.5) 应该返回 1.因为1.5插入到数组[1,2,3,4]后变成[1,1.5,2,3, ...

  2. Python 守护线程

    import time from threading import Thread from multiprocessing import Process #守护进程:主进程代码执行运行结束,守护进程随 ...

  3. [配置] win下maven配置

    下载解压 打开环境变量 新建MAVEN_HOME 路径为maven根文件夹 PATH 末尾添加 %MAVEN_HOME%\bin; 命令行 mvn -v 检查 添加网易maven镜像库 阿里的也可以 ...

  4. git教程:管理修改

    转载:管理修改 现在,假定你已经完全掌握了暂存区的概念.下面,我们要讨论的就是,为什么Git比其他版本控制系统设计得优秀,因为Git跟踪并管理的是修改,而非文件. 你会问,什么是修改?比如你新增了一行 ...

  5. Deepest left leaf node in a binary tree

    Recursion selfcontained recursion global variables outside of recursion Recursion Design  Whenever r ...

  6. 2018上C语言程序设计(高级)作业- 第4次作业成绩及总结

    作业地址 https://edu.cnblogs.com/campus/hljkj/CS2017-01/homework/1842 评分准则 第4次作业各项成绩包括三项: 完成WC项目:60分:基本功 ...

  7. 【EMV L2】GPO响应以及AIP、AFL

    [GPO命令] 终端通过GPO(Get Processing Options)命令 通知卡片交易开始.命令数据为PDOL指定的终端数据. [GPO响应] 卡片在GPO命令的响应中返回AIP和AFL:A ...

  8. [转]如何正确学习JavaScript

    原文:How to Learn JavaScript Properly(2014-2-7) 学习时长:6-8周 学习前提:中学水平,无需编程经验 更新(2014-1-7) 在Reddit上创建了一个学 ...

  9. 垃圾回收(GC Garbage collection)

    JS有自动垃圾清理机制, 如果有不需要用的对象,只需要设置对象=null即可 Var a = new object() a = null

  10. win10磁盘/cpu占用100%问题

    https://www.zhihu.com/question/27664545 https://www.zhihu.com/question/27664545 微软自己的解决办法 https://su ...