centos8使用yum源安装mysql8

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 这里大概记录一下使用yum源安装mysql8的一个记录。

QQ图片20220426230220.jpg

Mysql8已经发布有一段时间了,虽然我不太喜欢这个玩意(我是mariadb的忠实用户)但是,架不住客户喜欢。


人就是喜欢mysql,mariadb是啥人不知道。


这里大概记录一下使用yum源安装mysql8的一个记录。


1:为yum配置mysql8.0的源


vi /etc/yum.repos.d/mysql-community-server.repo


内容:


# Enable to use MySQL 8.0
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


2:安装命令:


yum install mysql-server


3:启动命令:


service mysqld start
systemctl start mysqld


4:链接数据库


Mysql安装成功之后,会生成初始密码在日志文件中。或者密码直接是空。


这个具体要参照你的mysql日志文件:


我的日志文件所在地:/var/log/mysql/mysqld.log


也有一些同学的日志所在目录是/var/log/mysqld.log


2020-09-26T02:27:21.581631Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-09-26T02:27:25.063785Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.21) starting as process 2043


上边是我安装mysql8的时候的日志,明确告诉我密码是空。


因此这里直接登录就可以了。


mysql -uroot -p


5:没有找到初始密码的情况


假如你安装的mysql有初始密码,并且你还没有找到你初始密码是什么。不要急,有办法。


找到你的mysql配置文件my.cnf,使用命令


[root@iZuf60ynur81p6k0ysvtneZ /]# whereis my.cnf
my: /etc/my.cnf


在当前文件下的[mysqld]下添加skip-grant-tables:免密登录


修改后的文件如下:


[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/run/mysqld/mysqld.pid
skip-grant-tables


重启mysql:


systemctl restart mysqld


使用mysql命令登录,刚刚修改的配置文件就是免密登录。


[root@iZuf60ynur81p6k0ysvtneZ /]# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 13
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>


然后使用命令修改root用户的密码:


ALTER USER 
'root'
@
'localhost'
 IDENTIFIED BY 
'12345678'
;


可能会报错:


ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cann


修改方法其实很简单:


运行


flush privileges;


执行成功之后,在执行


ALTER USER 
'root'
@
'localhost'
 IDENTIFIED BY 
'12345678'
;


命令,即成功。


剩下的数据库配置操作,请参考我之前的文章《Centos7.6配置lnmp》里边有详细的介绍。



相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
2月前
|
缓存
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
98 0
|
6月前
|
Linux
通过HTTP方式自建CentOS系列Yum源
通过HTTP方式自建CentOS系列Yum源
|
2月前
|
Linux 应用服务中间件 网络安全
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
284 0
|
2月前
|
缓存 Linux
Centos7中搭建本地yum源
Centos7中搭建本地yum源
130 0
|
5月前
|
Linux 应用服务中间件 nginx
CentOS7搭建yum源仓库(阿里源)
CentOS7搭建yum源仓库(阿里源)
965 0
|
5月前
|
缓存 Linux
CentOS7配置阿里yum源 超详细!!!
CentOS7配置阿里yum源 超详细!!!
6131 0
|
8天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
44 0
|
29天前
|
Linux
centOS8不在维护,yum源问题解决
解决执行 yum makecache 出现appstream下载源数据失败问题
59 0
centOS8不在维护,yum源问题解决
|
5月前
|
Linux
Centos8安装yum源时候出现的异常问题及解决方案(保好使)
Centos8安装yum源时候出现的异常问题及解决方案(保好使)
|
1月前
|
Linux
linux centos6.8系统配置网络yum源
linux centos6.8系统配置网络yum源
72 0