root@obdserver ~]# rpm -qa | grep mysql
因为没有mysql,所以也不用卸载
[root@obdserver ~]# ll /etc/yum.repos.d/
总用量 40
-rw-r--r--. 1 root root 2523 3月 12 01:22 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
[root@obdserver ~]# wget -P /usr/software http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
-bash: wget: 未找到命令
[root@obdserver ~]# yum install wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 wget.x86_64.0.1.14-18.el7_6.1 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================
Package 架构 版本 源 大小
====================================================================================
正在安装:
wget x86_64 1.14-18.el7_6.1 base 547 k
事务概要
====================================================================================
安装 1 软件包
总下载量:547 k
安装大小:2.0 M
Is this ok [y/d/N]: y
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : wget-1.14-18.el7_6.1.x86_64 1/1
验证中 : wget-1.14-18.el7_6.1.x86_64 1/1
已安装:
wget.x86_64 0:1.14-18.el7_6.1
完毕!
[root@obdserver ~]# wget -P /usr/software http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
--2025-03-17 23:06:29-- http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.49.112.119, 2600:1417:8400:b90::1d68, 2600:1417:8400:bad::1d68
正在连接 repo.mysql.com (repo.mysql.com)|23.49.112.119|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:5824 (5.7K) [application/x-redhat-package-manager]
正在保存至: “/usr/software/mysql-community-release-el6-5.noarch.rpm”
100%[==========================================>] 5,824 14.7KB/s 用时 0.4s
2025-03-17 23:06:30 (14.7 KB/s) - 已保存 “/usr/software/mysql-community-release-el6-5.noarch.rpm” [5824/5824])
[root@obdserver ~]#
[root@obdserver ~]# mkdir -p /usr/software
[root@obdserver ~]# cd /usr/software
[root@obdserver software]# rpm -ivh mysql-community-release-el6-5.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-release-el6-5 ################################# [100%]
[root@obdserver software]# yum -y install mysql-community-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql56-community | 2.6 kB 00:00:00
(1/3): mysql-tools-community/x86_64/primary_db | 81 kB 00:00:00
(2/3): mysql-connectors-community/x86_64/primary_db | 82 kB 00:00:01
(3/3): mysql56-community/x86_64/primary_db | 338 kB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.5.6.51-2.el6 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.6.51-2.el6,它被软件包 mysql-community-server-5.6.51-2.el6.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 5.6.10,它被软件包 mysql-community-server-5.6.51-2.el6.x86_64 需要
--> 正在处理依赖关系 net-tools,它被软件包 mysql-community-server-5.6.51-2.el6.x86_64 需要
--> 正在处理依赖关系 perl(DBI),它被软件包 mysql-community-server-5.6.51-2.el6.x86_64 需要
--> 正在处理依赖关系 perl(Data::Dumper),它被软件包 mysql-community-server-5.6.51-2.el6.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.5.6.51-2.el6 将被 安装
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 5.6.10,它被软件包 mysql-community-client-5.6.51-2.el6.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.5.6.51-2.el6 将被 安装
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
---> 软件包 perl-DBI.x86_64.0.1.627-4.el7 将被 安装
--> 正在处理依赖关系 perl(RPC::PlServer) >= 0.2001,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在处理依赖关系 perl(RPC::PlClient) >= 0.2000,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
---> 软件包 perl-Data-Dumper.x86_64.0.2.145-3.el7 将被 安装
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.68-1.el7 将被 取代
---> 软件包 mysql-community-libs.x86_64.0.5.6.51-2.el6 将被 舍弃
---> 软件包 perl-PlRPC.noarch.0.0.2020-14.el7 将被 安装
--> 正在处理依赖关系 perl(Net::Daemon) >= 0.13,它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Test),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Log),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Zlib),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在检查事务
---> 软件包 perl-IO-Compress.noarch.0.2.061-2.el7 将被 安装
--> 正在处理依赖关系 perl(Compress::Raw::Zlib) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Raw::Bzip2) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
---> 软件包 perl-Net-Daemon.noarch.0.0.48-5.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-Compress-Raw-Bzip2.x86_64.0.2.061-3.el7 将被 安装
---> 软件包 perl-Compress-Raw-Zlib.x86_64.1.2.061-4.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================
Package 架构 版本 源 大小
====================================================================================
正在安装:
mysql-community-libs x86_64 5.6.51-2.el6 mysql56-community 2.2 M
替换 mariadb-libs.x86_64 1:5.5.68-1.el7
mysql-community-server x86_64 5.6.51-2.el6 mysql56-community 62 M
为依赖而安装:
mysql-community-client x86_64 5.6.51-2.el6 mysql56-community 20 M
mysql-community-common x86_64 5.6.51-2.el6 mysql56-community 340 k
net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
事务概要
====================================================================================
安装 2 软件包 (+10 依赖软件包)
总下载量:87 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.51-2.el6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-common-5.6.51-2.el6.x86_64.rpm 的公钥尚未安装
(1/12): mysql-community-common-5.6.51-2.el6.x86_64.rpm | 340 kB 00:00:01
(2/12): mysql-community-libs-5.6.51-2.el6.x86_64.rpm | 2.2 MB 00:00:07
(3/12): net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
(4/12): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(5/12): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(6/12): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(7/12): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(8/12): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
(9/12): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(10/12): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(11/12): mysql-community-client-5.6.51-2.el6.x86_64.rpm | 20 MB 00:00:33
(12/12): mysql-community-server-5.6.51-2.el6.x86_64.rpm | 62 MB 00:01:08
------------------------------------------------------------------------------------
总计 1.1 MB/s | 87 MB 01:17
从 file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
用户ID : "MySQL Release Engineering "
指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
软件包 : mysql-community-release-el6-5.noarch (installed)
来自 : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : mysql-community-common-5.6.51-2.el6.x86_64 1/13
正在安装 : perl-Data-Dumper-2.145-3.el7.x86_64 2/13
正在安装 : mysql-community-libs-5.6.51-2.el6.x86_64 3/13
正在安装 : mysql-community-client-5.6.51-2.el6.x86_64 4/13
正在安装 : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 5/13
正在安装 : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 6/13
正在安装 : perl-IO-Compress-2.061-2.el7.noarch 7/13
正在安装 : net-tools-2.0-0.25.20131004git.el7.x86_64 8/13
正在安装 : perl-Net-Daemon-0.48-5.el7.noarch 9/13
正在安装 : perl-PlRPC-0.2020-14.el7.noarch 10/13
正在安装 : perl-DBI-1.627-4.el7.x86_64 11/13
正在安装 : mysql-community-server-5.6.51-2.el6.x86_64 12/13
正在删除 : 1:mariadb-libs-5.5.68-1.el7.x86_64 13/13
验证中 : perl-Net-Daemon-0.48-5.el7.noarch 1/13
验证中 : perl-Data-Dumper-2.145-3.el7.x86_64 2/13
验证中 : mysql-community-server-5.6.51-2.el6.x86_64 3/13
验证中 : mysql-community-common-5.6.51-2.el6.x86_64 4/13
验证中 : perl-IO-Compress-2.061-2.el7.noarch 5/13
验证中 : net-tools-2.0-0.25.20131004git.el7.x86_64 6/13
验证中 : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/13
验证中 : mysql-community-libs-5.6.51-2.el6.x86_64 8/13
验证中 : mysql-community-client-5.6.51-2.el6.x86_64 9/13
验证中 : perl-DBI-1.627-4.el7.x86_64 10/13
验证中 : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 11/13
验证中 : perl-PlRPC-0.2020-14.el7.noarch 12/13
验证中 : 1:mariadb-libs-5.5.68-1.el7.x86_64 13/13
已安装:
mysql-community-libs.x86_64 0:5.6.51-2.el6
mysql-community-server.x86_64 0:5.6.51-2.el6
作为依赖被安装:
mysql-community-client.x86_64 0:5.6.51-2.el6
mysql-community-common.x86_64 0:5.6.51-2.el6
net-tools.x86_64 0:2.0-0.25.20131004git.el7
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBI.x86_64 0:1.627-4.el7
perl-Data-Dumper.x86_64 0:2.145-3.el7
perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7
perl-PlRPC.noarch 0:0.2020-14.el7
替代:
mariadb-libs.x86_64 1:5.5.68-1.el7
完毕!
测试是否安装成功
[root@obdserver software]# rpm -qa| grep mysql
mysql-community-release-el6-5.noarch
mysql-community-common-5.6.51-2.el6.x86_64
mysql-community-libs-5.6.51-2.el6.x86_64
mysql-community-client-5.6.51-2.el6.x86_64
mysql-community-server-5.6.51-2.el6.x86_64
Starting mysqld (via systemctl): [ 确定 ]
[root@obdserver software]# yum install initscripts
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 initscripts.x86_64.0.9.49.53-1.el7 将被 升级
---> 软件包 initscripts.x86_64.0.9.49.53-1.el7_9.1 将被 更新
--> 解决依赖关系完成
依赖关系解决
====================================================================================
Package 架构 版本 源 大小
====================================================================================
正在更新:
initscripts x86_64 9.49.53-1.el7_9.1 updates 440 k
事务概要
====================================================================================
升级 1 软件包
总下载量:440 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
initscripts-9.49.53-1.el7_9.1.x86_64.rpm | 440 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : initscripts-9.49.53-1.el7_9.1.x86_64 1/2
清理 : initscripts-9.49.53-1.el7.x86_64 2/2
验证中 : initscripts-9.49.53-1.el7_9.1.x86_64 1/2
验证中 : initscripts-9.49.53-1.el7.x86_64 2/2
更新完毕:
initscripts.x86_64 0:9.49.53-1.el7_9.1
完毕!
[root@obdserver software]# /usr/bin/mysqladmin -u root password '123'
Warning: Using a password on the command line interface can be insecure.
[root@obdserver software]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
[root@obdserver software]# /usr/bin/mysqladmin -u root password '123'
Warning: Using a password on the command line interface can be insecure.
[root@obdserver software]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> >/etc/my.cnf
-> /etc/my.cnf
->
[1]+ 已停止 mysql -uroot -p123
[root@obdserver software]# >/etc/my.cnf
[root@obdserver software]# vi /etc/my.cnf
[root@obdserver software]# service mysqld restart
Restarting mysqld (via systemctl):
[ 确定 ]
[root@obdserver software]#
[root@obdserver software]#
[root@obdserver software]# show variables like 'character_set_%';
-bash: show: 未找到命令
[root@obdserver software]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by '123' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>