当前位置:网站首页>【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; #刷新权限


边栏推荐
猜你喜欢

Comprendre le principe AQS (organigramme et schéma de file d'attente synchrone)

Cookie encryption 10

想转行,但不知道自己要做什么工作比较好?

Mobaihe cm201-2-ch-hi3798mv300-300h-emmc and NAND_ Infrared Bluetooth voice_ Brush firmware package

The first technology podcast month will begin soon

画画水族馆的应用特色及功能

JS prototype and prototype chain (Lantern Festival meal)

js返回内容被unicode编码

C language output integer in another format

Embedded exit (review and release)
随机推荐
Varnish 基础概览6
Repair method for win10 subsystem WSL if the passwords of root and other users are forgotten
cookie加密8
Varnish foundation overview 6
TP-LINK configure WiFi authentication method for wireless Internet SMS
js Array. Five convenient applications of from()
JS recursive summation 1-100
MySQL monitoring 2
Cookie encryption 11
The national industrial information security development research center issued the report on industrial information security situation in 2021
C语言 说反话
C language I want to pass
cookie加密8
Pytorch模型训练到哪里找预训练模型?
JS prototype and prototype chain (Lantern Festival meal)
js内容混淆,返回内容加密
【图神经网络】图分类学习研究综述[3]:图分类方法评价及未来研究方向
画画水族馆的应用特色及功能
Spark 离线开发框架设计与实现
C language score ranking