卸载内置环境
检查是否有mariadb和mysql服务
c++
ps ajx |grep mariadb
ps ajx |grep mysql

停止mysql服务
c++
systemctl stop mysqld
找到mysql安装包
c++
rpm -qa | grep mysql
删除安装包
c++
rpm -qa | grep mysql | xargs yum -y remove

检查
ls /etc/my.cnf

ls /var/lib/mysql/

配置官方yum源
查看环境版本
c++
cat /etc/redhat-release

当前版本是8.2
Index of /232905
选择mysql57-community-release-el7版本
新建一个MySQL的路径
mkdir MySQL
将下载的yum源上传进来

查看系统默认支持的yum源
c++
ls /etc/yum.repos.d/ -l

安装yum源
c++
rpm -ivh mysql57-community-release-el7.rpm


可以支持安装mysql
查找mysql相关内容
c++
yum list | grep mysql

安装mysql
先禁用mysql模块
c++
yum module disable mysql
再开始安装mysql
c++
yum -y install mysql-community-server
如果出现GPG问题
导入较新的密钥
c++
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
安装成功

检查是否安装
c++
ls /etc/my.cnf

找到my.cnf文件
找mysql服务端的软件mysqld
c++
which mysqld

c++
which mysql

启动服务
c++
systemctl start mysqld.service
查看服务
c++
ps axj |grep mysqld

c++
netstat -ntlp

登录mysql
修改配置文件
c++
vim /etc/my.cnf

添加上一行
c++
skip-grant-tables
重启mysql服务
c++
systemctl restart mysqld
进入
c++
mysql -uroot -p

mysql
show databases;

mysql
quit;
退出

设置配置文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
port=3306
character-set-server=utf8
default-storage-engine=innodb
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-grant-tables
重启服务
systemctl restart mysqld
查看服务
netstat -nltp
