MySQL环境搭建

MySQL

环境搭建

一、卸载不需要的MySQL环境

shell 复制代码
#1.关闭服务
systemctl stop mysql
#2.查找MySQL安装包,并删除
rpm -qa;xargs yum remove -y 

二、获取MySQL官方yum源

c++ 复制代码
http://repo.mysql.com/
根据系统版本下载对应的文件;然后使用rz将文件传递到Linux机器上;

三、安装MySQL官方yum源

c++ 复制代码
rpm -ivh 对应yum源

四、安装MySQL

c++ 复制代码
yum install -y mysql-community-server

Failing package is: mysql-community-libs-5.7.44-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
//若遇到此问题,密钥过期问题,按照如下指令解决
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

//检查安装是否成功,就是存在/etc/my.conf,which mysqld;
mysqld是超级管理员管理的服务端,mysql是普通用户使用的客户端;

五、启动MySQL

shell 复制代码
systemctl start mysqld

六、登录MySQL

6.1第一种登陆方式

shell 复制代码
#1.获取临时密码
grep 'temporary password' /var/log/mysqld.log 
#2.登录
mysql -uroot -p
set global validate_password_policy=0;

set global validate_password_length=1;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'dyh@163.com';

FLUSH PRIVILEGES;

6.2第二种登录方式

shell 复制代码
打开对应的配置文件/etc/my.conf,在最后一栏添加skip-grant-tables选项并保存退出,即设置免密码
重启服务systemctl restart mysqld==systemctl stop mysqld;systemctl start mysqld;

七、配置my.cnf文件

shell 复制代码
port=3306
character-set-server=utf8
default-storage-engine=innodb
skip-grant-tables

八、设置自启动

shell 复制代码
#1.服务自启动
systemctl enable 服务
#2.守护进程重新加载
systemctl dameon-reload 
相关推荐
Coder_Boy_23 分钟前
基于SpringAI的智能平台基座开发-(六)
java·数据库·人工智能·spring·langchain·langchain4j
热爱专研AI的学妹44 分钟前
数眼搜索API与博查技术特性深度对比:实时性与数据完整性的核心差异
大数据·开发语言·数据库·人工智能·python
hopsky1 小时前
ShardingSphere功能简介
数据库·sql
talenteddriver1 小时前
mysql: MySQL索引和排序相关名词概念汇总
数据库·mysql
6极地诈唬1 小时前
【PG漫步】DELETE不会改变本地文件的大小,VACUUM也不会
linux·服务器·数据库
MZWeiei2 小时前
Redis持久化机制中的 AOF机制简单介绍
数据库·redis
Elastic 中国社区官方博客3 小时前
Elasticsearch:在 X-mas 吃一些更健康的东西
android·大数据·数据库·人工智能·elasticsearch·搜索引擎·全文检索
酷柚易汛3 小时前
酷柚易汛ERP 2025-12-26系统升级日志
java·前端·数据库·php
wang6021252183 小时前
阿里云存储的一些简要概述
数据库·阿里云·fastapi
小徐Chao努力4 小时前
【Langchain4j-Java AI开发】08-向量嵌入与向量数据库
java·数据库·人工智能