当前位置:   article > 正文

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

mysql-community-client(x86-64) >= 8.0.11 is needed by mysql-community-server

系统: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之类的工具连接了,如果不能连接请检查防火墙设置。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/449557
推荐阅读
相关标签
  

闽ICP备14008679号