忘忧的小站

  • 首页
  • 文章归档
  • 日志
  • 关于页面

  • 搜索
分布式索引 索引 全文搜索 Lucene.Net GPS 音视频 过滤 AOP 时区 升级 ABP.Zero 数据备份 linux 阿里云盘 aliyunpan 面试题 Signalr S 汉字 css html 前端 拼音键盘 在线键盘 uniapp .Net Core XMLRPC Serilog LOKI Nlog 分布式日志 加密 总结 人生 Asp.Net Core Swagger Web Element-plus Quasar 匹配 JavaScript 正则 .Net 后台 架构师 Redis EF CORE MySQL 自考 英语 集群 Jenkins CI/DI 内网穿透 代理 ABP 学习 后端 软考

CentOS7.6安装MySQL8.0

发表于 2021-12-31 | 分类于 linux | 2 | 阅读次数 1216

增加yum 源

rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

安装MySQL8 社区版

由于MySQL yum库有多个版本的多个库配置,你需要在MySQL repo文件中禁用所有库:

sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

然后用以下命令安装

yum --enablerepo=mysql80-community install mysql-community-server

这个时候可能会出现错误 Unable to find a match: mysql-community-server

输入以下解决问题,然后再重新运行安装命令

yum module disable mysql

启动MySQL服务

service mysqld start

获取随机默认root密码

grep "A temporary password" /var/log/mysqld.log

这行命令会输出如下信息

[Note] A temporary password is generated for root@localhost: hjkygMukj5+t783

这个密码是临时命令我们需要拿来配置MySQL_Init

初始化MySQL服务

 mysql_secure_installation

然后会要求你输入root密码 输入通过命令得到密码

Enter password for user root:

这里会要求你输入一个新的密码 密码格式 Test123.

The existing password for the user account root has expired. Please set a new password.

New password:
Re-enter new password:

输入新密码后有一些配置需要配置

You will need to enter the new password for the root‘s account twice. It will prompt for some questions, it is recommended to type yes (y):

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
//是否要删除匿名用户
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
//是否要禁用远程连接

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
//是否要删除测试数据库
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
//刷新用户权限表

重启MySQL服务并设置开机启动MySQL

service mysqld restart
chkconfig mysqld on

连接MySQL服务

mysql -u root -p

输入root密码就可以连接进去了

mysql>

使用SHOW DATABASES 命令查看现有数据库

show databases;

这里会输出

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.05 sec)

那么到了这里,恭喜你正确的在CentOS 7.6上安装了MySQL8.0

  • 本文作者: 忘忧
  • 本文链接: /archives/69
  • 版权声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0 许可协议。转载请注明出处!
# MySQL
正则逐个替换img标签内容
Quasar Vue3 引入Element plus 框架爬坑
  • 文章目录
  • 站点概览
忘忧

忘忧

君子藏器于身,待时而动,何不利之有

44 日志
6 分类
60 标签
RSS
Github E-mail StackOverflow
Creative Commons
0%
© 2025 忘忧
由 Halo 强力驱动