mysql新增用户
新开了个项目,数据库也想新搞个用户,先登陆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新增用户的更多相关文章
- 解决MySQL新增用户无法登陆问题
1. 新增用户 grant all on *.* to '库名'@'%' identified by '库名'; 2. 刷新授权表 flush privileges; 3. 删除空用户 use mys ...
- 5.7.27版本mysql新增用户
因为我们目前只有root,所以只能先用root登陆mysql,再新增用户: $ bin/mysql -u root -p Enter password: Welcome to the MySQL mo ...
- mysql新增用户无法登陆问题解决ERROR 1045 (28000)
mysql增加新用户无法登陆解决方法 ERROR 1045 (28000): Access denied for user 'appadmin'@'localhost' (using password ...
- Mysql新增用户,权限管理
MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant selec ...
- MySQL新增用户及赋予权限
创建用户 USE mysql; #创建用户需要操作 mysql 表 # 语法格式为 [@'host'] host 为 'localhost' 表示本地登录用户,host 为 IP地址或 IP 地址区间 ...
- MySQL新增用户以及数据库访问授权
# mysql -u root -p # 允许本地 IP 访问 localhost, 127.0.0.1 # insert into mysql.user(Host,User,Password) va ...
- mysql新增用户并开启远程连接
之前使用mysql一直使用root来连接登录数据库,现在想使用新的用户名来连接数据库,碰到数据连接不上的情况. 把这些记录下来,以备后用 1.首先,创建用户 CREATE USER 'xiazhenx ...
- mysql新增用户无法授权!? 解决方案
先上解决方法 :) 创建用户cat 密码 CREATE USER '; 修改user表中的注册用户cat update user set host='%' where user='cat'; 授权: ...
- ubuntu mysql新增用户并开启远程连接
1.首先用root用户登录mysql mysql -u root -p 输入密码后登录成功 2.新建用户 use mysql; select host,user from user;(查看现有用户) ...
随机推荐
- (1)jmeter录制脚本(使用代理的方式)
(1)jmeter录制脚本(使用代理的方式) jmeter 2018年07月09日 17时27分24秒 很多APP使用badboy是无法录制的,这种情况下需要使用chrome或Firefox,如果能联 ...
- Discuz! X3 数据字典
pre_common_admincp_cmenu 后台菜单收藏表 字段名 数据类型 默认值 允许非空 自动递增 备注 id smallint(6) unsigned NO 是 title v ...
- jmeter5.1企业级应用功能详解
apache jmeter是100%的java桌面应用程序,它被设计用来加载被测试软件功能特性.度量被测试软件的性能.jmeter可以模拟大量的服务器负载,并且jmeter提供图形化的性能分析. JM ...
- Go语言 - 包(package)
在工程化的Go语言开发项目中,Go语言的源码复用是建立在包(package)基础之上的.本文介绍了Go语言中如何定义包.如何导出包的内容及如何导入其他包. Go语言的包(package) 包介绍 包( ...
- nginx,apache,tomcat的区别
nginx与apache 这里说的apche指apache http server ,与nginx都属于http服务器软件,主要处理静态资源. http server关心的是http协议层面的传输和访 ...
- &和&& 每天学一点linux
原文:http://www.cnblogs.com/TianFang/archive/2013/01/23/2872645.html & 放在启动参数后面表示设置此进程为后台进程 默认情况下, ...
- 开源项目(5-2) yolo打包成库
Windows系统下YOLO动态链接库的封装和调用 Windows10+VS2015+OpenCV3.4.1+CUDA8.0+cuDNN8.0 参考教程 https://blog.csdn.net/s ...
- (11)树莓派3 有线网卡静态IP设置
https://www.cnblogs.com/10e-6/p/5778355.html 树莓派设置静态IP地址 首先终端输入: ifconfig 查看树莓派默认分配的动态IP地址. 图 1-4 配置 ...
- make命令与Makefile(转载)
概述博客内容包含linux下make命令的使用与makefile的书写规则等,希望通过本文档使读者对make命令makefile文件有进一步了解,由于鄙人经验学识有限文档中会有描述不准确以及理解偏差, ...
- MySQL InnoDB 群集–在Windows上设置InnoDB群集
InnoDB集群最需要的功能之一是Windows支持,我们现在已将其作为InnoDB Cluster 5.7.17预览版 2的一部分提供.此博客文章将向您展示如何在MS Windows 10上运行In ...