当前位置:网站首页>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.log
A 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的安装完美完成
边栏推荐
- The principle of complete replication of virtual machines (cloud computing)
- Installation, start and stop of redis7 under Linux
- What have I experienced to become a tester who is harder than development?
- Force buckled brush the stairs (7/30)
- mysql 索引
- 12 磁盘相关命令
- Clustering index, and what is the difference between a clustering index
- 10 权限介绍
- 知识蒸馏7:知识蒸馏代码详解
- Problems that need to be solved by the tcp framework
猜你喜欢
曼城推出可检测情绪的智能围巾,把球迷给整迷惑了
Observer mode (1)
What does a software test report contain?
Inter-vlan routing + static routing + NAT (PAT + static NAT) comprehensive experiment
Unity界面总体介绍
mmdetection训练一个模型相关命令
221. Largest Square
Manchester City confuses fans with smart scarf that detects emotions
String为什么不可变?
Detailed explanation of STP election (step + case)
随机推荐
静态路由解析(最长掩码匹配原则+主备路由)
Basic introduction to ShardingJDBC
Shell script to loop through values in log file to sum and calculate average, max and min
The Sad History of Image Processing Technology
Face detection based on opencv
Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
Real-time image acquisition based on FPGA
Intel's software and hardware optimization empowers Neusoft to accelerate the arrival of the era of smart medical care
Fiddler captures packets to simulate weak network environment testing
[1153] The boundary range of between in mysql
JS 函数 this上下文 运行时点语法 圆括号 数组 IIFE 定时器 延时器 self.备份上下文 call apply
My first understanding of MySql, and the basic syntax of DDL and DML and DQL in sql statements
英特尔软硬优化,赋能东软加速智慧医疗时代到来
Huawei od dice js
To write good test cases, you must first learn test design
Unity界面总体介绍
mmdetection trains a model related command
General introduction to the Unity interface
Detailed explanation of STP election (step + case)
系统需求多变如何设计