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
相关推荐
慕白Lee3 分钟前
【PostgreSQL】日常总结
数据库·postgresql
sc.溯琛8 分钟前
MySQL 视图实战:简化查询与数据安全管控指南
数据库
风月歌10 分钟前
小程序项目之校园二手交易平台小程序源代码(源码+文档)
java·数据库·mysql·小程序·毕业设计·源码
西格电力科技16 分钟前
绿电直连架构适配技术的发展趋势
大数据·服务器·数据库·架构·能源
计算机毕设VX:Fegn089521 分钟前
计算机毕业设计|基于springboot + vue汽车销售系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·汽车·课程设计
@小白向前冲35 分钟前
数据库创表(方便自己查看)
数据库·mysql
散一世繁华,颠半世琉璃37 分钟前
高并发下的 Redis 优化:如何利用HeavyKeeper快速定位热 key
数据库·redis·缓存
IT枫斗者37 分钟前
Java 开发实战:从分层架构到性能优化(Spring Boot + MyBatis-Plus + Redis + JWT)
java·spring boot·sql·mysql·性能优化·架构
咸鱼加辣1 小时前
【前端的crud】DOM 就是前端里的“数据库”
前端·数据库
loosed1 小时前
ubuntu navicat17连接本机msyql8 /run/mysqld/mysqld.sock问题
linux·mysql·ubuntu·adb