当前位置:网站首页>【值得收藏】Centos7 安装mysql完整操作命令
【值得收藏】Centos7 安装mysql完整操作命令
2022-06-27 10:53:00 【InfoQ】
前言
准备
实操
1.卸载
pkill -9 mysqld
rpm -qa|grep -i mysql
yum -y remove mysql-community-client-5.6.38-2.el7.x86_64
卸载不掉的用 rpm -ev

2.下载mysql的repo源
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpmrpm -qpl mysql57-community-release-el7-7.noarch.rpmrpm -ivh mysql57-community-release-el7-7.noarch.rpmyum list mysql*yum install mysql-community-servermysql -V3.设置mysql密码
systemctl stop mysqld.servicevi /etc/my.cfg# Disabling symbolic-links is recommended to prevent assorted security risks
skip-grant-tables #添加这句话,这时候登入mysql就不需要密码
symbolic-links=0systemctl start mysqld.serviceset password for [email protected]=password('123456'); or update user set authentication_string=PASSWORD("123456") where user="root";mysql -u root -p #输入命令回车进入,出现输入密码提示直接回车。
mysql> set password for [email protected] = password('123456');
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for [email protected] = password('123456'); or update user set authentication_string=PASSWORD("123456") where user="root";
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>flush privileges; #更新权限
mysql>quit; #退出MySQL8.0
grep 'temporary password' /var/log/mysqld.log //生成随机密码 mysql -uroot -p //使用随机密码登陆1.修改用户名对应的密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码'; //修改密码create user [email protected]'%' identified by '你的密码';
grant all privileges on *.* to [email protected]'%' with grant option;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
flush privileges; #更新权限2.修改/etc/my.cnf 添加skip-grant-tables跳过验证登录
vim /etc/my.cnf //修改my.cnf文件
//在[mysqld]后面任意一行添加"skip-grant-tables"用来跳过密码验证的过程,保存退出。
mysql -uroot -p //登录,不需要密码
//登录成功:
use mysql; //切换到mysql库
select host,user,authentication_string from user; //可以查看root用户的host及密码(加密后)
3.mysql8.0去除了password字段,更改为authentication_string
update user set authentication_string = '' where user = 'root';
//将密码置为空,my.cnf去掉skip-grant-tables依旧可以空密码登录。
vim /etc/my.cnf
//编辑my.cnf文件 去掉之前添加的"skip-grant-tables",依旧可以空密码登录
show variables like 'validate_password%';

validate_password.check_user_name 用户名检测
validate_password.dictionary_file 指定密码验证的文件路径;
validate_password.length 固定密码的总长度;
validate_password.mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
validate_password.number_count 整个密码中至少要包含阿拉伯数字的个数;
validate_password.policy 指定密码的强度验证等级,默认为 MEDIUM;
关于 validate_password_policy 的取值:
0/LOW:只验证长度;
1/MEDIUM:验证长度、数字、大小写、特殊字符;
2/STRONG:验证长度、数字、大小写、特殊字符、字典文件;
validate_password.special_char_count 整个密码中至少要包含特殊字符的个数set global validate_password.policy=LOW; //设置密码强度为LOW
策略修改完后,修改密码:
alter user 'root'@'localhost' identified by 'root'; //修改密码为root,提示修改成功边栏推荐
- What basic functions are required for live e-commerce application development? What is the future development prospect?
- Leetcode to do questions
- Based on swift admin's rapid background development framework, I made a rookie tutorial [professional version]
- border影响父元素的高度-解决方案
- JS all network request modes
- audiotrack与audioflinger
- deep learning statistical arbitrage
- Oracle-多表查询
- Co jump
- [tcapulusdb knowledge base] tcapulusdb machine initialization and launch introduction
猜你喜欢

The tutor invites you to continue your doctoral study with him. Will you agree immediately?

Win10 shortcut key sorting

Audiotrack and audiolinker

oracle触发器 存储过程同时写入

Future & CompletionService

C语言学习-Day_06

iMeta:高颜值绘图网站imageGP+视频教程合集,已被引360次(220625更新)

Go zero micro Service Practice Series (VII. How to optimize such a high demand)

How to deploy jupyterlab in methodot?

红包雨: Redis 和 Lua 的奇妙邂逅
随机推荐
Uniform Asymptotics by Alexei
【HCIE-RS复习思维导图】- STP
C apprentissage des langues - jour 12.
Test how students participate in codereview
Native JS implements page scroll bar loading data and page drop-down loading content
VPT Model Video Explanation
[从零开始学习FPGA编程-47]:视野篇 - 第三代半导体技术现状与发展趋势
学习笔记之——数据集的生成
【TcaplusDB知识库】TcaplusDB集群管理介绍
NVME2.0协议——新特性
Oracle连接MySQL报错IM002
Mongodb cross host database copy and common commands
上周热点回顾(6.20-6.26)
How to deploy jupyterlab in methodot?
一篇抄十篇,CVPR Oral被指大量抄袭
软交换呼叫中心系统的支撑系统
If you find any loopholes later, don't tell China!
The tutor invites you to continue your doctoral study with him. Will you agree immediately?
【TcaplusDB知识库】TcaplusDB机器初始化和上架介绍
Glide caching mechanism