Linux通过rpm包安装mysql5.7.22

2 篇文章 0 订阅
1 篇文章 0 订阅

准备工作:
1.首先登陆mysql官网下载页面
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
2.选择相应的选项并下载rpm包
Select Version:5.7.22
Select Operating System:Red Hat Enterprise Linux / Oracle Linux
Select OS Version:Red Hat Enterprise Linux 7/ Oracle Linux 7 (x86,64-bit)
选择完毕在下方选择mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar下载
3.安装系统

[root@zk1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@zk1 ~]#

1.上传并解压rpm包

[root@zk1 opt]#mkdir mysql
[root@zk1 opt]#mv mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar ./mysql
[root@zk1 opt]#cd mysql/
[root@zk1 mysql]#tar -xvf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
[root@zk1 mysql]#ll
total 1168028
-rw-r--r-- 1 root root  598026240 Mar  5 10:44 mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415  25106088 Mar  5 10:24 mysql-community-client-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    280800 Mar  5 10:24 mysql-community-common-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   3781636 Mar  5 10:24 mysql-community-devel-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  46742952 Mar  5 10:24 mysql-community-embedded-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  24078476 Mar  5 10:24 mysql-community-embedded-compat-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 129955496 Mar  5 10:24 mysql-community-embedded-devel-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2239868 Mar  5 10:24 mysql-community-libs-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2116356 Mar  5 10:24 mysql-community-libs-compat-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  55743828 Mar  5 10:24 mysql-community-minimal-debuginfo-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 172992596 Mar  5 10:25 mysql-community-server-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  15255560 Mar  5 10:25 mysql-community-server-minimal-5.7.22-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 119716756 Mar  5 10:25 mysql-community-test-5.7.22-1.el7.x86_64.rpm

2.删除maridb

[root@zk1 mysql]#rpm -qa | grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@zk1 mysql]#rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64

3.由于有依赖关系,依次安装以下四个包

[root@zk1 mysql]#rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
[root@zk1 mysql]#rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
[root@zk1 mysql]#rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
[root@zk1 mysql]#rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        /usr/bin/perl is needed by mysql-community-server-5.7.22-1.el7.x86_64
        net-tools is needed by mysql-community-server-5.7.22-1.el7.x86_64
        perl(Getopt::Long) is needed by mysql-community-server-5.7.22-1.el7.x86_64
        perl(strict) is needed by mysql-community-server-5.7.22-1.el7.x86_64

#依赖报错安装相应的包
[root@zk1 mysql]#yum install net-tools
[root@zk1 mysql]#yum install perl
#依赖包安装完成在继续安装刚才报错rpm包
[root@zk1 mysql]#rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm

4.启动mysql

[root@zk1 mysql]#service mysqld start
#获取密码
[root@zk1 usr]#grep 'temporary password' /var/log/mysqld.log
2018-07-28T08:03:36.165230Z 1 [Note] A temporary password is generated for root@localhost: Zc?H2OJE65ub
#登陆mysql
[root@zk1 usr]#mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22

Copyright (c) 2000, 2018, 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> set password=password('tianpy5@');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#由于密码简单,不符合策略,改为包含字母和数字,大小写,特殊字符的字符串
mysql>  set password=password('Tian_0801');
#授权访问
mysql> grant all privileges on *.* to root@'%' identified by 'Tian_0801';
mysql> flush privileges;

5.配置文件修改字符编码

[root@zk1 ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character_set_server=utf8
collation-server=utf8_general_ci

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

6.设置开机自启动,并重启mysql

[root@zk1 ~]# systemctl enable mysqld
[root@zk1 ~]# systemctl restart mysqld
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值