新开了个项目,数据库也想新搞个用户,先登陆mysql,看看原来都有哪些:

root@wlf:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select host,user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | backup |
| % | hellodevelop |
| % | hellocloud |
| % | passerby |
| % | hellomg |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)

  我们新增一个prize用户:

mysql> create user 'prize'@'%' identified by 'prize';
Query OK, rows affected (0.11 sec) mysql> select host,user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | backup |
| % | hellodevelop |
| % | hellocloud |
| % | passerby |
| % | prize |
| % | hellomg |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)

  

  但这会儿新用户是没有任何操作权限的,除了看看:

mysql> show grants for 'prize'@'%';
+-----------------------------------+
| Grants for prize@% |
+-----------------------------------+
| GRANT USAGE ON *.* TO 'prize'@'%' |
+-----------------------------------+
row in set (0.00 sec)

  

  所以我们还得给它赋予各种权限:

mysql> grant all privileges on `prize`.* to 'prize'@'%';
Query OK, rows affected (0.04 sec) mysql> show grants for 'prize'@'%';
+--------------------------------------------------+
| Grants for prize@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO 'prize'@'%' |
| GRANT ALL PRIVILEGES ON `prize`.* TO 'prize'@'%' |
+--------------------------------------------------+
rows in set (0.00 sec)

  刷新一下权限:

mysql> flush privileges;
Query OK, rows affected (0.09 sec)

  现在可以进入prize用户开始我们的倒腾了:

mysql> exit;
Bye
root@d5afa9102517:/# mysql -uprize -pprize
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database prize;
Query OK, row affected (0.09 sec)

mysql新增用户的更多相关文章

  1. 解决MySQL新增用户无法登陆问题

    1. 新增用户 grant all on *.* to '库名'@'%' identified by '库名'; 2. 刷新授权表 flush privileges; 3. 删除空用户 use mys ...

  2. 5.7.27版本mysql新增用户

    因为我们目前只有root,所以只能先用root登陆mysql,再新增用户: $ bin/mysql -u root -p Enter password: Welcome to the MySQL mo ...

  3. mysql新增用户无法登陆问题解决ERROR 1045 (28000)

    mysql增加新用户无法登陆解决方法 ERROR 1045 (28000): Access denied for user 'appadmin'@'localhost' (using password ...

  4. Mysql新增用户,权限管理

    MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant selec ...

  5. MySQL新增用户及赋予权限

    创建用户 USE mysql; #创建用户需要操作 mysql 表 # 语法格式为 [@'host'] host 为 'localhost' 表示本地登录用户,host 为 IP地址或 IP 地址区间 ...

  6. MySQL新增用户以及数据库访问授权

    # mysql -u root -p # 允许本地 IP 访问 localhost, 127.0.0.1 # insert into mysql.user(Host,User,Password) va ...

  7. mysql新增用户并开启远程连接

    之前使用mysql一直使用root来连接登录数据库,现在想使用新的用户名来连接数据库,碰到数据连接不上的情况. 把这些记录下来,以备后用 1.首先,创建用户 CREATE USER 'xiazhenx ...

  8. mysql新增用户无法授权!? 解决方案

    先上解决方法  :) 创建用户cat 密码 CREATE USER '; 修改user表中的注册用户cat update user set host='%' where user='cat'; 授权: ...

  9. ubuntu mysql新增用户并开启远程连接

    1.首先用root用户登录mysql mysql -u root -p 输入密码后登录成功 2.新建用户 use mysql; select host,user from user;(查看现有用户) ...

随机推荐

  1. Odoo中的记录集

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826218.html 一:record set 1:获取记录集 1)在@api.multi修饰器修饰的函数 ...

  2. jmeter针对websocket协议的压测

    之前一直没有接触过websocket协议,所以一直对websocket的压测存在疑惑,在网上参考文章并不断尝试之后,终于有所得:第一次用jmeter的websoket插件,用的ws非加密协议,请求都能 ...

  3. 错误 Unable to connect to a repository at URL 'svn://ip地址' 和 No repository found in 'svn://ip地址'

    SVN服务器是CentOS6.10 使用TortoiseSVN客户端检出时遇到如下图所示的错误: 是因为没有指定SVN仓库的路径 在SVN服务器执行命令:svnserve -d -r /SVN版本库的 ...

  4. jenkins中jmeter项目流程图

  5. oVirt部署

    所有前提建议: 关闭防火墙.selinux,配置hosts,计算机名使用域名 ovirt-engine部署 yum install http://resources.ovirt.org/pub/yum ...

  6. Spring Cloud 组件 —— gateway

    Spring Cloud 网关主要有三大模块:route.predicates.filters 其中 filter 最为关键,是功能增强的核心组件. 列举出一些功能组件: 5.6 CircuitBre ...

  7. PHP 验证Email的函数

    <?php   function validateEmail($email) {    $isValid = true;    $atIndex = strrpos($email, " ...

  8. 一个Java字符串中到底有多少个字符?

    依照Java的文档, Java中的字符内部是以UTF-16编码方式表示的,最小值是 \u0000 (0),最大值是\uffff(65535), 也就是一个字符以2个字节来表示,难道Java最多只能表示 ...

  9. http编程体系结构URL loading system

    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadi ...

  10. Quick Start NodeMCU / ESP8266 12E

    先说明一下:本来想买常见的ESP 8266作为Arduinoi的WIFI模块,结果错买成ESP 8266 12E,发现网上的资料比较少. ESP8266是WIFI芯片,它只是一块芯片必须要搭配相应的电 ...