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
相关推荐
小马过河R8 小时前
真实场景:用户自建定时任务与推送提醒Agent-架构设计与可靠性实践
数据库·人工智能·agent·vibe coding·ai coding
鹤落晴春10 小时前
【MySQL】 | 两阶段提交、主从复制
运维·数据库·mysql
SelectDB10 小时前
中小企业数据仓库怎么选?按数据规模、BI 并发和国产化要求分三档
数据库
SelectDB10 小时前
数据仓库一年要花多少钱?云数仓、自建 Doris 成本拆解与 TCO 计算指南
数据库
码少女11 小时前
MySQL——复杂查询
数据库·mysql
codeejun12 小时前
每日一Go·MySQL-20、SQL 性能调优实战总结
sql·mysql·golang
CoderYanger13 小时前
Java EE 进阶:11. SpringBoot 统一功能处理(第四弹):@ControllerAdvice 源码分析+案例代码
java·数据库·spring boot·后端·spring·java-ee·mybatis
TDengine (老段)13 小时前
TDengine 读缓存与 LAST 查询完全指南
大数据·数据库·物联网·缓存·时序数据库·tdengine·涛思数据
FungLeo15 小时前
FengCMS · PHP+MySQL 升级实录 · 输出转义的度:面包屑双重编码、默认转义与 cms_html()信任声明
mysql·html·php·fengcms·输出转义
Decay__16 小时前
PostgreSQL 用户权限与安全 —— 角色体系、GRANT 授权、pg_hba.conf 认证、行级安全与审计
运维·数据库·sql·postgresql