redhat7.3 yum安装mysql

参考官网

https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html

下载yum仓库安装文件

https://dev.mysql.com/downloads/repo/yum/
下载对应的yum rpm包,此过程需要登录oracle账号,获取下载连接

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@localhost home]# ls -la mysql80-community-release-el7-1.noarch.rpm 
-rw-r--r--. 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@localhost home]# 

安装yum仓库

[root@localhost home]# yum localinstall mysql80-community-release-el7-1.noarch.rpm 
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
Marking mysql80-community-release-el7-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                                    Arch                    Version                   Repository                                                Size
=============================================================================================================================================================
Installing:
 mysql80-community-release                  noarch                  el7-1                     /mysql80-community-release-el7-1.noarch                   31 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package

Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 6 pre-existing rpmdb problem(s), 'yum check' output follows:
ipa-admintools-4.4.0-12.el7.noarch has installed conflicts freeipa-admintools: ipa-admintools-4.4.0-12.el7.noarch
ipa-client-4.4.0-12.el7.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.x86_64
ipa-client-common-4.4.0-12.el7.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.noarch
ipa-common-4.4.0-12.el7.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.noarch
ipa-server-4.4.0-12.el7.x86_64 has installed conflicts freeipa-server: ipa-server-4.4.0-12.el7.x86_64
ipa-server-common-4.4.0-12.el7.noarch has installed conflicts freeipa-server-common: ipa-server-common-4.4.0-12.el7.noarch
  Installing : mysql80-community-release-el7-1.noarch                                                                                                    1/1 
  Verifying  : mysql80-community-release-el7-1.noarch                                                                                                    1/1 

Installed:
  mysql80-community-release.noarch 0:el7-1                                                                                                                   

Complete!
[root@localhost home]# yum repolist enabled | grep "mysql.*-community.*"

允许mysql相关仓库

[root@localhost home]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64       MySQL Connectors Community        51
mysql-tools-community/x86_64            MySQL Tools Community             63
mysql80-community/x86_64                MySQL 8.0 Community Server        17
[root@localhost home]# 

查看mysql对应版本信息

[root@localhost home]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community       disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - Sou disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community       disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - Sou disabled
mysql-connectors-community/x86_64  MySQL Connectors Community        enabled: 51
mysql-connectors-community-source  MySQL Connectors Community - Sour disabled
mysql-tools-community/x86_64       MySQL Tools Community             enabled: 63
mysql-tools-community-source       MySQL Tools Community - Source    disabled
mysql-tools-preview/x86_64         MySQL Tools Preview               disabled
mysql-tools-preview-source         MySQL Tools Preview - Source      disabled
mysql55-community/x86_64           MySQL 5.5 Community Server        disabled
mysql55-community-source           MySQL 5.5 Community Server - Sour disabled
mysql56-community/x86_64           MySQL 5.6 Community Server        disabled
mysql56-community-source           MySQL 5.6 Community Server - Sour disabled
mysql57-community/x86_64           MySQL 5.7 Community Server        disabled
mysql57-community-source           MySQL 5.7 Community Server - Sour disabled
mysql80-community/x86_64           MySQL 8.0 Community Server        enabled: 17
mysql80-community-source           MySQL 8.0 Community Server - Sour disabled
[root@localhost home]# 

开启需要安装的版本

默认开启mysql8.0版本,禁用8.0版本,启动5.7版本

yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community

安装mysql5.7

  • 确认当前yum启动的版本
[root@localhost home]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64       MySQL Connectors Community         51
mysql-tools-community/x86_64            MySQL Tools Community              63
mysql57-community/x86_64                MySQL 5.7 Community Server        267
[root@localhost home]# 

  • 安装mysql5.7
[root@localhost home]# yum install mysql-community-server
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-server.x86_64 0:5.7.22-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.22-1.el7 for package: mysql-community-server-5.7.22-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.22-1.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.52-1.el7 will be obsoleted
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-client.x86_64 0:5.7.22-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.22-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.22-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-5.7.2-24.el7_2.1.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.22-1.el7 will be obsoleting
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-libs-compat.x86_64 0:5.7.22-1.el7 will be obsoleting
--> Finished Dependency Resolution
Error: Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda/7.3)
           Requires: mariadb-server
           Removing: 1:mariadb-server-5.5.52-1.el7.x86_64 (@anaconda/7.3)
               mariadb-server = 1:5.5.52-1.el7
           Obsoleted By: mysql-community-server-5.7.22-1.el7.x86_64 (mysql57-community)
               Not found
 You could try using --skip-broken to work around the problem
** Found 6 pre-existing rpmdb problem(s), 'yum check' output follows:
ipa-admintools-4.4.0-12.el7.noarch has installed conflicts freeipa-admintools: ipa-admintools-4.4.0-12.el7.noarch
ipa-client-4.4.0-12.el7.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.x86_64
ipa-client-common-4.4.0-12.el7.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.noarch
ipa-common-4.4.0-12.el7.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.noarch
ipa-server-4.4.0-12.el7.x86_64 has installed conflicts freeipa-server: ipa-server-4.4.0-12.el7.x86_64
ipa-server-common-4.4.0-12.el7.noarch has installed conflicts freeipa-server-common: ipa-server-common-4.4.0-12.el7.noarch

发生报错:没有卸载mariadb

[root@localhost home]# rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
mariadb-5.5.52-1.el7.x86_64
mariadb-server-5.5.52-1.el7.x86_64
[root@localhost home]# 

rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64
  • 再次执行安装命令
yum install mysql-community-server
Installed:
  mysql-community-server.x86_64 0:5.7.22-1.el7                                                                                                               

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.22-1.el7        mysql-community-common.x86_64 0:5.7.22-1.el7        mysql-community-libs.x86_64 0:5.7.22-1.el7       

Complete!

查看msyql版本

[root@localhost home]# systemctl start mysqld
[root@localhost home]# mysql --version
mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper
[root@localhost home]# 

5.7版本默认生成了root密码

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

修改mysql密码和远程登录

mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
use mysql;
update user set host='%' where user='root' and host='localhost';
flush privileges;

修改默认字符集

/etc/my.cnf
[mysqld]下面增加
character-set-server=utf8
重启mysql

兼容5.6的一些设置

character-set-server=utf8
lower_case_table_names=1 #忽略大小写
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,948评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,371评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,490评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,521评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,627评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,842评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,997评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,741评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,203评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,534评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,673评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,339评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,955评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,770评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,000评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,394评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,562评论 2 349

推荐阅读更多精彩内容