卸载内置环境
ps ajx |grep mariadb
ps ajx |grep mysql
停止mysql服务
systemctl stop mysqld
找到mysql安装包
rpm -qa | grep mysql
删除安装包
rpm -qa | grep mysql | xargs yum -y remove
检查
ls /etc/my.cnf
ls /var/lib/mysql/
配置官方yum源
查看环境版本
cat /etc/redhat-release
当前版本是8.2
Index of /232905
选择mysql57-community-release-el7版本
新建一个MySQL的路径
mkdir MySQL
将下载的yum源上传进来
查看系统默认支持的yum源
ls /etc/yum.repos.d/ -l
安装yum源
rpm -ivh mysql57-community-release-el7.rpm
可以支持安装mysql
查找mysql相关内容
yum list | grep mysql
mysql_72">安装mysql
先禁用mysql模块
yum module disable mysql
再开始安装mysql
yum -y install mysql-community-server
如果出现GPG问题
导入较新的密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
安装成功
检查是否安装
ls /etc/my.cnf
找到my.cnf文件
which mysqld
which mysql
启动服务
systemctl start mysqld.service
查看服务
ps axj |grep mysqld
netstat -ntlp
mysql_124">登录mysql
修改配置文件
vim /etc/my.cnf
添加上一行
skip-grant-tables
重启mysql服务
systemctl restart mysqld
进入
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