前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >MySQL 用户管理

MySQL 用户管理

作者头像
技能锦囊
发布于 2020-04-15 08:13:07
发布于 2020-04-15 08:13:07
2.4K00
代码可运行
举报
文章被收录于专栏:MySQL 笔记MySQL 笔记
运行总次数:0
代码可运行

一、MySQL的连接方式

1.远程连接(IP + 端口)
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
mysql -h192.168.3.1 -P3306 -uroot -p密码
 -h IP地址、 -P 端口号(默认3306)
为了保障远程安全连接,
一般都会禁止最高权限的root账号登录,
Linux系统也是如此...
2.本地连接 (localhost)
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
mysql -uroot -p密码

#查看服务器所有连接会话
mysql> show full processlist;

#退出 MySQL服务器
mysql> exit  
mysql> quit  
mysql> \q

二、MySQL 内置库

MySQL初始化时生成的四个库

内置库

作用

information_schema

系统库,记录元数据,库名或表名,列的数据类型,访问权限等,也叫 “数据字典”

mysql

记录用户权限日志等信息;

performance_schema

收集数据库服务器性能参数从MySQL5.6开始默认打开

sys

简化performance_schema库方便DBA管理

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#SQL命令查看所有库
mysql> show databases;

MySQL用户密码管理

1. 连接数据库
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
mysql -uroot -p123456
2.创建普通用户

创建用户需要有对 mysql库 的操作权限,因为创建用户其实就是在 mysql 库中的 user表进行添加用户与权限的对应记录

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
create user 用户名@登录方式 identified by '密码';
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#登录方式有以下三个选项:
1) % :不限制用户的连接方式

2) 192.168.1.% :代表可以允许客户端以192.168.1.0/24网段的IP地址进行访问,  
或者某个特定的ip地址,则只允许配置了特定ip地址的电脑连接MySQL

3) localhost :代表只能通过Mysql服务器端进行本地连接,通常是限制root

注意:可以存在不同的登录方式但用户名相同;
create user 语句创建的用户没有权限;
需要使用grant语句赋权.
3.修改用户密码
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
1)grant 赋权改密,如果用户不存在,则新建该用户 (推荐此方法创建用户)
grant all on *.*  to username@localhost identified by 'password';

2)使用PASSWORD函数重置密码
update mysql.user set authentication_string=PASSWORD('new-password')   
where user='root' and  host='localhost';

3)修改当前用户密码:
    set PASSWORD=PASSWORD('new-password');

   修改其他用户密码:
     set password for root@‘localhost’=password('new-password');
       
4)使用alter user 方式修改密码
alter user root@localhost identified by '123456';

5) 切记!更改用户密码权限等信息后要刷新权限或重启MySQL生效 !! 
flush privileges;  

#查看当前用户的权限
show grants;

#查看用户的密码期限
select user,host,
password_expired,
password_last_changed,
password_lifetime 
from mysql.user;

注意:因为用户密码修改就是对mysql库中user表的数据修改, 所以得先确定当前登录用户是否有对mysql库的修改权限...

4.删除某个用户
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
drop user username@'localhost';

#用户重命名
rename user 'A'@'localhost' to 'B'@'localhost';
5.用户权限赋值与回收

权限赋值的作用是对服务端的库或表及数据的操作权限管理; 例: 配置某个库内全部的读与更新权限

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
赋值:grant select,update  on mysql.* to username@'localhost';

回收:revoke select,update on mysql.* from username@'localhost';
6.查看用户信息
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#查看当前登陆用户:
select user();

#查看某个用户权限:
show grants for root@'localhost';

by~

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-03-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 技能锦囊 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
SAP最佳业务实践:SD–带变式价格的销售报价(663)-4创建订单
一、 VA01 Deriving Order from Follow-On Quotation Aftercomparing various quotations with various configurations for configurable material, the customer decideson the last quotation. To optimize the order creation process, the order iscreated with reference t
SAP最佳业务实践
2018/03/28
1K0
SAP最佳业务实践:SD–带变式价格的销售报价(663)-4创建订单
SAP最佳业务实践:SD–带变式价格的销售报价(663)-3修改报价
一、 VA23 Outputting Quotation Document After the quotation has been created in the system, it has to be output and sent to thecustomer by fax, e-mail, or post. The output of the quotation is controlled bymessage control, in other words, the correct message
SAP最佳业务实践
2018/03/28
4.3K0
SAP最佳业务实践:SD–带变式价格的销售报价(663)-3修改报价
SAP最佳业务实践:SD–带变式价格的销售报价(663)-2创建报价单
一、VA21Creating Quotation Header The customer inquires about a configurable material and requests a quotation. Thefirst step is to create the quotation header. If you want to use this scenario with a credit limitcheck, use the sold-to-party 100000. Thecusto
SAP最佳业务实践
2018/03/28
2.8K0
SAP最佳业务实践:SD–带变式价格的销售报价(663)-2创建报价单
从SAP最佳业务实践看企业管理(160)-LE-D34运输管理
Transportation is an essential element inthe logistics chain. It affects both incoming and outgoing goods. Effectivetransportation planning and processing ensure that shipments are dispatchedwithout delay and arrive on schedule. Transportation costs play a
SAP最佳业务实践
2018/03/27
9910
从SAP最佳业务实践看企业管理(160)-LE-D34运输管理
SAP S/4 HANA新变化-SD销售与分销
1、数据库表变化 简化了数据模型: 取消了状态表VBUK, VBUP,状态表相关字段移到了销售对象表中,包括VBAK 、VBAP、LIKP、 LIPS、VBRK。  Simplification of Document Flow tableVBFA 简化了凭证流表VBFA  Field length extension of SD documentcategory: Data element VBTYP (Char1) has been replaced by data element VBTYPL
SAP最佳业务实践
2018/03/28
2.1K0
SAP S/4 HANA新变化-SD销售与分销
SAP S/4HANA最佳业务实践:Order-to-Cash订单到收款-4报价单处理
•The tile Manage Sales Quotationsis part of the business catalog Sales –Quotation Processing. The sales representative can use this tile to launch the list report application based on SAP Fiori. •The business catalog has to be assigned to business users
SAP最佳业务实践
2018/03/28
9890
SAP S/4HANA最佳业务实践:Order-to-Cash订单到收款-4报价单处理
SAP S/4HANA最佳业务实践:Order-to-Cash订单到收款-1概览
SAP S/4HANA Suite S/4HANA Enterprise Management: Optimized Order to Cash订单到收款优化 S/4HANA Sales Busin
SAP最佳业务实践
2018/03/28
2K0
SAP S/4HANA最佳业务实践:Order-to-Cash订单到收款-1概览
SAP S/4 HANA新变化-CO物料帐(for Ver.1610)
Material Ledger Actual Costing has been activated already in the system before the system conversion to SAP S/4HANA. You can verify if Material Ledger Actual Costing is active for one or more plants via SAP Reference IMG / SAP Customizing Implementation Gu
SAP最佳业务实践
2018/03/28
5.4K0
SAP S/4 HANA新变化-CO物料帐(for Ver.1610)
SAP最佳业务实践:SD–售前活动(920)-1业务概览
用途 This scenario describes the pre-sales business processes usingthe functions for inquiries, quotations and contracts.nThe inquiry is used to enter a request from the customer intothe system to either provide him with a sales quotation or to store the i
SAP最佳业务实践
2018/03/28
1.1K0
SAP最佳业务实践:SD–售前活动(920)-1业务概览
「翻译」SAP变式配置的完整指南(中英文双语版)
A Complete Guide of SAP Variant Configuration SAP变式配置的完整指南
SAP虾客
2021/09/23
1.8K0
SAP S/4 HANA新变化-MM-IM物料帐:物料评估
Material Ledger Obligatory for Material Valuation 物料帐强制启用 Description This simplification makes it mandatory to use the Material Ledger (ML) in all SAP S/4HANA systems. After the technical SUM migration, the Material Ledger needs to be migrated. Relevant I
SAP最佳业务实践
2018/03/28
1.9K0
SAP S/4 HANA新变化-MM-IM物料帐:物料评估
SAP S/4HANA最佳业务实践:Order-to-Cash订单到收款-5订单处理
•The tile Manage Sales Orders is part of the business catalog Sales –Sales Order Processing. The sales representative can use this tile to launch the list report application based on SAP Fiori. •The business catalog has to be assigned to business users v
SAP最佳业务实践
2018/03/28
2K0
SAP S/4HANA最佳业务实践:Order-to-Cash订单到收款-5订单处理
Software Engineering Terms Collection 1
This note collect all terms occur in SEPP Lecture 1/2/4/5. It would be helpful to recap what has learnt and what has already been abstracted away.
杨丝儿
2022/03/01
2700
The ERS function in SAP MM is not applicable to vendor consignment purchase mode
The ERS function in SAP MM is not applicable to vendor consignment purchase mode
SAP虾客
2022/01/14
4560
相关推荐
SAP最佳业务实践:SD–带变式价格的销售报价(663)-4创建订单
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档