当前位置:网站首页>CentOS7下mysql5.7.37的安装【完美方案】
CentOS7下mysql5.7.37的安装【完美方案】
2022-07-31 02:30:00 【倾心*】
不在CentOS安装mysql8.0的原因是对于一些中间件不兼容 比如mycat 会出现意想不到的bug 比如mycat连接mysql状态是连接成功,但是却进入不到数据库里面 出现数据库卡顿 报1184错误的现象 所以希望大家学习虚拟机的时候 mysql建议安装成mysql5.7的 本人亲自从mysql8.0.28回退到mysql5.7.37 中间各种错误 太痛苦了 所以在此提供mysql的安装与卸载教程 方便大家后续操作
centos下mysql安装步骤
进入官网MySQL :: Download MySQL Community Server (Archived Versions)
选择Red Hat Linux 7 与 centos7是一样的 互相兼容
选择版本和对应系统 下载第一个包 mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar

查看是否有系统自带的mariadb和mysql
[[email protected] ~]# rpm -qa |grep mysql
[[email protected] ~]# rpm -qa |grep postfix
[[email protected] ~]# rpm -qa |grep mariadb卸载命令
rpm -e --nodeps xxx安装需要的依赖文件
yum -y install libaio
yum -y install net-tools
yum -y install perl安装mysql5.7.37
最好将mysql一系列的文件归到一个文件夹里 然后在这个目录下解压
tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar按照顺序安装以下文件 必须按照顺序安装
rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpm此外这里在提供mysql8.0.28的安装顺序,与mysql5.7还是有点区别的
1. mysql-community-common
2. mysql-community-client-plugins
3. mysql-community-libs
4. mysql-community-client
5. mysql-community-icu-data-files
6. mysql-community-server启动mysql
先查看mysql的状态
命令1:
service mysqld status命令2:
systemctl status mysqld
启动mysql服务
命令1
service mysqld start命令2
systemctl start mysqld
查看mysql进程
ps -ef | grep mysqld设置mysql开机自启(根据自身需求 可要可不要)
systemctl enable mysqld #设置开机启动
systemctl disable mysqld #关闭开机启动获取mysql初始化密码
MySQL服务初始化密码是自动生成的我们需要通过查询 mysqld.log查询初始化密码
grep password /var/log/mysqld.logA temporary password is generated for [email protected]: xxxxxx
(xxxxxx这就是初始密码 进入mysql复制即可)
登录MySQL修改初始化密码
mysql -uroot -p初始化密码没修改的情况下是无法使用mysql服务的会提示必须充值秒才能进行操作
重置密码
mysql> set password = password("123456");
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+MySQL5.7版本的密码默认策略如下
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+如果密码设置的过于简单系统会提示不满足当前策略 会出现以下错误
[[email protected] opt]# mysql -uroot -p
mysql> set password = password("123456");
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements开发测试环境嫌麻烦的话可以通过以下命令修改密码策略
mysql> set global validate_password_policy=LOW;
mysql> set global validate_password_length=6;再次查看默认密码策略
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 6 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)再次重置简单密码成功
mysql> set password = password("123456");
Query OK, 0 rows affected, 1 warning (0.00 sec)设置mysql远程访问权限
需要在命令行执行开启远程访问命令
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)客户端连接MySQL服务
默认情况下Centos防火墙是开启状态 通过以下命令查询防火墙状态
systemctl status firewalld方式1 关闭防火墙(企业环境不推荐)
# 关闭
systemctl stop firewalld.service
# 禁用
systemctl disable firewalld方式2 开放mysql服务端口
# 添加需要放行的端口号
firewall-cmd --add-port=端口号/tcp --zone=public --pernament
# 移除需要放行的端口号
firewall-cmd --remove-port=端口号/tcp --zone=public --pernament
# 查看放行的端口号
firewall-cmd --list-ports启动防火墙
# 开启
systemctl start firewalld.service
# 重启
systemctl restart firewalld.service关闭或者放行端口号之后发现远程访问成功

至此centos下mysql的安装完美完成
边栏推荐
- vlan间路由+静态路由+NAT(PAT+静态NAT)综合实验
- LeetCode 每日一题 2022/7/25-2022/7/31
- 【C语言基础】解决C语言error: expected ‘;‘, ‘,‘ or ‘)‘ before ‘&‘ token
- 【AcWing 62nd Weekly Game】
- Validate XML documents
- Intel's software and hardware optimization empowers Neusoft to accelerate the arrival of the era of smart medical care
- ShardingJDBC usage summary
- Static route analysis (the longest mask matching principle + active and standby routes)
- Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
- Installation, start and stop of redis7 under Linux
猜你喜欢

Between two orderly array of additive and Topk problem

STM32CUBEMX开发GD32F303(11)----ADC在DMA模式下扫描多个通道

Layer 2 broadcast storm (cause + judgment + solution)

mmdetection trains a model related command

经典链表OJ强训题——快慢双指针高效解法

16. Registration Center-consul

StringJoiner详解

MPPT solar charge controller data collection - through the gateway acquisition capacity battery SOC battery voltage, wi-fi

Drools规则属性,高级语法

Live Preview | KDD2022 Doctoral Dissertation Award Champion and Runner-up Dialogue
随机推荐
cudaMemcpy学习笔记
tcp框架需要解决的问题
Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
221. Largest Square
Static routing + PAT + static NAT (explanation + experiment)
真正的CTO,是一个懂产品的技术人
Coldfusion file read holes (CVE - 2010-2861)
[1154] How to convert string to datetime
AtCoder Beginner Contest 261 部分题解
How to expose Prometheus metrics in go programs
[1154]如何将字符串转换为datetime
coldfusion8 background scheduled tasks take shell
Intranet Infiltration - Privilege Escalation
leetcode-952: Calculate max component size by common factor
The comprehensive result of the case statement, do you know it?[Verilog Advanced Tutorial]
Go 项目实战-获取多级分类下的全部商品
二层广播风暴(产生原因+判断+解决)
【C语言基础】解决C语言error: expected ‘;‘, ‘,‘ or ‘)‘ before ‘&‘ token
print task sorting js od huawei
Difference between CMOS and TTL?