码迷,mamicode.com
首页 > 数据库 > 详细

Centos8上yum安装mysql8

时间:2020-12-14 13:49:14      阅读:4      评论:0      收藏:0      [点我收藏+]

标签:command   reserve   start   NPU   ==   res   lte   system   长度   

安装Yum Repository

[root@liujunjun ~]# wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm
--2020-12-08 08:06:16--  https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.215.59.160
正在连接 repo.mysql.com (repo.mysql.com)|23.215.59.160|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:30388 (30K) [application/x-redhat-package-manager]
正在保存至: “mysql80-community-release-el8-1.noarch.rpm”

mysql80-community-release-el8-1.noarch.rp 100%[====================================================================================>]  29.68K   166KB/s  用时 0.2s    

2020-12-08 08:06:17 (166 KB/s) - 已保存 “mysql80-community-release-el8-1.noarch.rpm” [30388/30388])

使用rpm来安装MySQL

[root@liujunjun ~]# rpm -ivh mysql80-community-release-el8-1.noarch.rpm
警告:mysql80-community-release-el8-1.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql80-community-release-el8-1  ################################# [100%]

使用yum安装mysql服务

[root@liujunjun ~]# yum install mysql-server

启动服务

[root@liujunjun ~]# systemctl start mysqld
[root@liujunjun ~]# systemctl enable mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@liujunjun ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
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密码

在MySQL 8.04前,执行:SET PASSWORD=PASSWORD(‘[新密码]’);但是MySQL8.0.4开始,这样默认是不行的。因为之前,MySQL的密码认证插件是“mysql_native_password”,而现在使用的是“caching_sha2_password”。

修改密码为123456(密码可以设置为任意值):

mysql> user mysql;
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 user mysql at line 1
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY 123456;
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> 
[root@liujunjun ~]# 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 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> 

 

Centos8上yum安装mysql8

标签:command   reserve   start   NPU   ==   res   lte   system   长度   

原文地址:https://www.cnblogs.com/liujunjun/p/14105774.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!