下载

https://dev.mysql.com/downloads/mysql/

进入官网,下载,选择对应的版本
在这里插入图片描述
2、选择以下的包

在这里插入图片描述
在这里插入图片描述

[root@localhost mysql]# ll
总用量 68432
-rw-r--r--. 1 root root 12706240 11月 28 15:38 mysql-community-client-8.0.22-1.el8.x86_64.rpm
-rw-r--r--. 1 root root   634576 11月 28 15:39 mysql-community-common-8.0.22-1.el8.x86_64.rpm
-rw-r--r--. 1 root root  1508128 11月 28 15:40 mysql-community-libs-8.0.22-1.el8.x86_64.rpm
-rw-r--r--. 1 root root 55218152 11月 28 15:34 mysql-community-server-8.0.22-1.el8.x86_64.rpm

下载完成,进行安装

安装

顺序如下
common
libs
client
server

1

rpm -ivh mysql-community-common-8.0.22-1.el8.x86_64.rpm

在这里插入图片描述
出现这个进度条就表示这个包安装成功

2

rpm -ivh mysql-community-libs-8.0.22-1.el8.x86_64.rpm 

也有可能出现这样的报错
在这里插入图片描述
在命令后面加上–force --nodeps
即可

rpm -ivh mysql-community-libs-8.0.22-1.el8.x86_64.rpm --force --nodeps
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-8.0.22-1.el8################################# [100%]

3

rpm -ivh mysql-community-client-8.0.22-1.el8.x86_64.rpm --force --nodeps
警告:mysql-community-client-8.0.22-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-8.0.22-1.e################################# [100%]

查看当前mysql安装情况,请看下图,如果你也有则证明可以继续进行了

[root@localhost mysql]# rpm -qa | grep mysql
mysql-community-client-8.0.22-1.el8.x86_64
mysql-community-libs-8.0.22-1.el8.x86_64
mysql-community-common-8.0.22-1.el8.x86_64

4

[root@localhost mysql]# rpm -ivh mysql-community-server-8.0.22-1.el8.x86_64.rpm --force --nodeps
警告:mysql-community-server-8.0.22-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-server-8.0.22-1.e################################# [100%]
[root@localhost mysql]# rpm -qa | grep mysql
mysql-community-client-8.0.22-1.el8.x86_64
mysql-community-libs-8.0.22-1.el8.x86_64
mysql-community-common-8.0.22-1.el8.x86_64
mysql-community-server-8.0.22-1.el8.x86_64

启动mysql服务

service mysqld start

但是出错了

查看rpm -qa|grep mariadb

[root@localhost mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@localhost mysql]# 

删除

[root@localhost mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@localhost mysql]# rpm -e --nodeps  mariadb-libs-5.5.65-1.el7.x86_64
[root@localhost mysql]# 

依然报错

[root@localhost mysql]# rm -rf /var/lib/mysql
[root@localhost mysql]# service mysqld restart

检查
[

root@localhost mysql]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since 六 2020-11-28 16:02:32 CST; 32s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 4936 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=127)
  Process: 4902 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 4936 (code=exited, status=127)

11月 28 16:02:32 localhost.localdomain systemd[1]: mysqld.service: main process exited, code=exited...n/a
11月 28 16:02:32 localhost.localdomain systemd[1]: Failed to start MySQL Server.
11月 28 16:02:32 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
11月 28 16:02:32 localhost.localdomain systemd[1]: mysqld.service failed.
11月 28 16:02:32 localhost.localdomain systemd[1]: mysqld.service holdoff time over, scheduling restart.
11月 28 16:02:32 localhost.localdomain systemd[1]: Stopped MySQL Server.
11月 28 16:02:32 localhost.localdomain systemd[1]: start request repeated too quickly for mysqld.service
11月 28 16:02:32 localhost.localdomain systemd[1]: Failed to start MySQL Server.
11月 28 16:02:32 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
11月 28 16:02:32 localhost.localdomain systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

卸载mysql

1、查看

[root@localhost opt]# rpm -qa |grep -i mysql
mysql-community-client-8.0.22-1.el8.x86_64
mysql-community-libs-8.0.22-1.el8.x86_64
mysql-community-common-8.0.22-1.el8.x86_64
mysql-community-server-8.0.22-1.el8.x86_64

2、yum remove 卸载

yum remove mysql-community-client.x86_64 
yum remove mysql-community-common.x86_64 

卸载两个即可

3、检查卸载干净与否

[root@localhost opt]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/etc/selinux/targeted/tmp/modules/100/mysql
/opt/mysql

挨个删除

[root@localhost opt]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/etc/selinux/targeted/tmp/modules/100/mysql
/opt/mysql
[root@localhost opt]# rm -rf /etc/selinux/targeted/active/modules/100/mysql
[root@localhost opt]# find / -name mysql
/etc/selinux/targeted/tmp/modules/100/mysql
/opt/mysql
[root@localhost opt]# rm -rf /etc/selinux/targeted/tmp/modules/100/mysql
[root@localhost opt]# find / -name mysql
/opt/mysql
[root@localhost opt]# rm -rf /opt/mysql/
[root@localhost opt]# 

使用yum安装mysql

1
https://dev.mysql.com/downloads/repo/yum/
在这里插入图片描述
2
下载后上传到/opt
在这里插入图片描述
3 安装yum源

 yum -y localinstall mysql80-community-release-el7-3.noarch.rpm

4、在线安装

yum -y install mysql-community-server
==========================================================================================================
 Package                               架构          版本                  源                        大小
==========================================================================================================
正在安装:
 mysql-community-server                x86_64        8.0.22-1.el7          mysql80-community        510 M
为依赖而安装:
 mysql-community-client                x86_64        8.0.22-1.el7          mysql80-community         48 M
 mysql-community-client-plugins        x86_64        8.0.22-1.el7          mysql80-community        235 k
 mysql-community-common                x86_64        8.0.22-1.el7          mysql80-community        616 k
 mysql-community-libs                  x86_64        8.0.22-1.el7          mysql80-community        4.6 M

事务概要
==========================================================================================================
安装  1 软件包 (+4 依赖软件包)

总下载量:563 M
安装大小:2.6 G
Downloading packages:

几分钟后
安装完成

应用

开启
systemctl start mysqld

cat /var/log/mysqld.log

在这里插入图片描述
如果使用临时密码无法登陆

vim /etc/my.cnf
加上
skip-grant-tables
在这里插入图片描述
重启之后就可以登陆了

[root@localhost opt]# systemctl restart mysqld
[root@localhost opt]# mysql -uroot

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

然后修改密码
update user set authentication_string=‘密码’ where User=‘root’; 或者5.6及以下版本使用:update user set Password=‘密码’ where User=‘root’; 然后FLUSH PRIVILEGES即可

在这里插入图片描述

新建库

mysql> create database nacos_config;
Query OK, 1 row affected (0.00 sec)

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nacos_config       |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

切换库

mysql> use nacos_config;
Database changed
show tables;
+------------------------+
| Tables_in_nacos_config |
+------------------------+
| config_info            |
| config_info_aggr       |
| config_info_beta       |
| config_info_tag        |
| config_tags_relation   |
| group_capacity         |
| his_config_info        |
| roles                  |
| tenant_capacity        |
| tenant_info            |
| users                  |
+------------------------+
11 rows in set (0.00 sec)
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐