0.MySQL安装|卸载内置环境|配置官方yum源|安装mysql|登录mysql|设置配置文件(centos8.2)

卸载内置环境

检查是否有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
相关推荐
smilejingwei9 分钟前
TRAE 插件上新 | SQLazy:让 AI 写出可信复杂 SQL
数据库·人工智能·sql
我要见SA姐114 分钟前
GitHub Actions 自动化:5 个真实运维提效案例
运维·数据库·机器学习·oracle·回归
IT规划师1 小时前
百亿数据写入 MySQL:空间降维 × IO 降维 × 工程兜底
mysql·sqlsugar·.net10
QXWZ_IA2 小时前
边坡监测预算有限时的建设顺序:虚拟基准站与成本账
网络·数据库
这个DBA有点耶2 小时前
1亿条向量内存降95.4%,延迟降80%:金仓AI原生内核真能解决RAG痛点?
数据库·人工智能·开源
Y3815326622 小时前
用 httpx 写 SerpBase 异步客户端:连接池与超时配置
运维·服务器·数据库
c_hn_0072 小时前
量化数据12:国内期货L2历史数据:Tick、逐笔、五档盘口一次性打包下载
数据库·1024程序员节·#深度订单簿数据·#历史行情订单薄·#本地csv数据存储
GeW2 小时前
从"补短板"到"强优势"Linux与数据库认证成为产业跃迁人才支点
linux·数据库
数据库小学妹3 小时前
MySQL NULL陷阱:NOT IN、三值逻辑与NOT EXISTS
数据库·后端·mysql