centos7手动安装mysql服务_CentOS7手动安装MySQL 8

本文详细记录了在CentOS 7.8系统中手动安装MySQL 8.0的过程,包括解决依赖问题、启动服务以及设置和授权root用户的密码。
摘要由CSDN通过智能技术生成

系统:CentOS 7.8(2003)版本最小化安装

MySQL:8.0.21

注意,页面上没有CentOS的选项,选择RedHat 7相关的系统就行,他们之间的关系不可描述,囧。

先下载了RPM Server包,以为能够一直安装过

cd /usr/lcoal/src

wget https://..........mysql-community-server-8.0.21-1.el7.x86_64.rpm #直接去页面上找地址

rpm -ivh mysql-community-server-8.0.21-1.el7.x86_64.rpm

结果发现缺少依赖包,囧。

警告:mysql-community-server-8.0.21-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

错误:依赖检测失败:

mysql-community-client(x86-64) >= 8.0.11 被 mysql-community-server-8.0.21-1.el7.x86_64 需要

mysql-community-common(x86-64) = 8.0.21-1.el7 被 mysql-community-server-8.0.21-1.el7.x86_64 需要

net-tools 被 mysql-community-server-8.0.21-1.el7.x86_64 需要

于是干脆下了mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar包。

gwet https://......../ mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar #自己去页面上找地址

tar -xvf mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar

yum -y install net-tools mariadb-libs

rpm -ivh mysql-community-common-8.0.21-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.21-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-8.0.21-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-8.0.21-1.el7.x86_64.rpm

顺序不能错,有依赖关系。

启动服务:

systemctl start mysqld.service

systemctl enable mysqld.service

查看MySQL初始密码,每次安装都会不一样,注意使用自己机器上的:

grep 'password' /var/log/mysqld.log

2020-07-16T03:01:40.135985Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: _hN6j8t_pWaO

用初始密码进入MySQL

mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 8.0.21 MySQL Community Server - GPL

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>

成功进入,修改密码:

mysql> alter user 'root'@'%' idenfified by 'wenfei@fly'; #报错,初始root用户在localhost下面,没有root@%用户。

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'idenfified by 'wenfei@fly'' at line 1

mysql> alter user 'root'@'localhost' identified by 'WenFei@123'; #先修改一次root@localhost用户,默认在本机登录

Query OK, 0 rows affected (0.01 sec)

user mysql;

create user 'root'@'%' identified by 'WenFei@123'; #创建root@%用户,方便其它IP登录访问数据库

#update user set host ='%' where user=‘root'; #也可以直接替换root@localhost为root@%用户

MySQL 8.0版本开始,密码默认使用的插件是caching_sha2_password,规则是大写、小写、字符、数字、至少8位,这些条件必须满足。如果要使用以前的mysql_native_password

ALTER USER `root`@`%` IDENTIFIED WITH mysql_native_password BY '123';

给root@%用户授权最大权限

grant all on *.* to root@'%';

好了,这时候可以用Navicat之类的工具连接了,如果不能连接请检查防火墙设置。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值