当前位置:网站首页>【MySQL 05】SUSE 12 SP5 安装MySQL后第一次修改mysql密码
【MySQL 05】SUSE 12 SP5 安装MySQL后第一次修改mysql密码
2022-06-30 01:50:00 【Rusty well began】
1、查看安装的MySQL版本:
命令:mysql --version

2、启动 MySQL 服务
启动 MySQL 服务:systemctl start mysql.service
重启 MySQL 服务:systemctl restart mysql.service
关闭 MySQL 服务:systemctl stop mysql.service

3、检查MySQL服务是否启动
方法1:systemctl list-unit-files|grep mysqld.service

方法2 :systemctl status mysql.service

4、设置密码
4.1 查看随机密码
rpm 安装 MySQL 会自动生成一个随机密码,可在 /var/log/mysqld.log 这个文件中查找该密码
命令:cat /var/log/mysql/mysqld.log |grep temp
Tips:如果不确定路径,可以使用find 命令查找mysqld.log 文件

4.2 使用随机密码登录
命令:mysql -uroot -ppCg3+El.c#ao

4.3 修改root用户密码
命令:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码‘;

这里可能会提示 Your password does not satisfy the current policy requirements,意思是您的密码不符合当前规定的要求,你要么就把你的密码设置得复杂点,要么就去降低密码的校验规则。
在 Linux 上安装 MySQL 时会自动安装一个校验密码的插件,默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。修改密码时新密码是否符合当前的策略,不满足则会提示ERROR;
官网上能查到这个密码校验的规则,文档中搜索:validate_password;

所以可以将这个限制密码位数设小一点,复杂度类型调底一点
# 将密码复杂度校验调整简单类型
set global validate_password.policy = 0;
# 设置密码最少位数限制为 9 位
set global validate_password.length = 9;


就可以设置较为简单的密码了。

5、创建用户与权限分配
<1> 默认的 root 用户只能当前节点localhost访问,是无法远程访问的,我们还需要创建一个新的账户,用于远程访问
语法格式:CREATE USER <用户名> [ IDENTIFIED ] BY [ PASSWORD ] <口令>
# mysql 8.0 以下
create user 'siteweb'@'%' IDENTIFIED BY 'siteweb1!';
# mysql 8.0
create user 'siteweb'@'%' IDENTIFIED WITH mysql_native_password BY 'siteweb1!';
Tips: mysql8.0 的默认密码验证不再是 password 。所以在创建用户时,create user ‘username’@‘%’ identified by ‘password’; 客户端是无法连接服务的,所以在创建用户的时候需要加上 WITH mysql_native_password

<2> 创建完用户之后还需要给用户分配权限,这里我将 siteweb 这个用户分配了所有的权限
grant all privileges on *.* to 'siteweb'@'%';
flush privileges; #刷新权限


边栏推荐
- js返回内容被unicode编码
- Sorting out the usage of transforms in pytoch
- Three questions from the boss
- C语言 数组元素循环右移问题
- JS content confusion, return content encryption
- 什么是幂等性?四种接口幂等性方案详解!
- OpenCV和Image之间的转换(亲测有效)
- cookie加密8
- C语言 数素数
- Pytoch modifies the hook source code to obtain per layer output parameters (with layer name)
猜你喜欢
随机推荐
Database application
假離婚變成真離婚,財產怎麼辦
Pytoch modifies the hook source code to obtain per layer output parameters (with layer name)
Pytorch模型训练到哪里找预训练模型?
[machine learning Q & A] cosine similarity, cosine distance, Euclidean distance and the meaning of distance in machine learning
画画水族馆的应用特色及功能
Cookie加密12
Cookie encryption 13
Mobaihe cm201-2-ch-hi3798mv300-300h-emmc and NAND_ Infrared Bluetooth voice_ Brush firmware package
Chiffrement des cookies 8
Using grpcui to test asp Net core grpc service
C语言 素数对猜想
Que se passe - t - il si un faux divorce devient un vrai divorce?
Design and implementation of spark offline development framework
OpenCV和Image之间的转换(亲测有效)
Repair method for win10 subsystem WSL if the passwords of root and other users are forgotten
DTW learning (dynamic time warping) -- Thought and code implementation
Mysql 监控3
Geotools wkt coordinate system conversion
The national industrial information security development research center issued the report on industrial information security situation in 2021






![【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类](/img/5f/b23b64eed7f28ffd92c122b6859e2d.png)


