mysql5.7 centos6 rpm_用rpm包在centos6.6安装mysql-5.7.29-1.el7.x86_64

一,准备工作。

查看系统版本:

[root@localhost ~]# uname -a

Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

[root@localhost ~]#

mysql的rpm包下载地址

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

dfc140ee43a6af6094c2946d281dac42.png

下载,mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 大小520.5M

卸载CentOS7.4系统自带的mariadb

[root@localhost ~]# rpm -qa|grep mysql

mysql-5.1.73-8.el6_8.x86_64

mysql-libs-5.1.73-8.el6_8.x86_64

rpm -e --nodeps mysql-5.1.73-8.el6_8.x86_64

[root@test01 ~]# rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64

[root@test01 ~]# rpm -qa|grep mysql

[root@test01 ~]# cd /etc

[root@test01 etc]# ll |grep my.cnf

[root@test01 etc]# cat my.cnf

cat: my.cnf: 没有那个文件或目录

解压

48304ba5e6f9fe08f3fa1abda7d326ab.png

[root@localhost mysql]# tar xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar

[root@test01 mysql]# ll

总用量 965308

-rw-r--r--. 1 root root  494233600 5月  14 13:19 mysql-5.7.29-1.el6.x86_64.rpm-bundle.tar

-rw-r--r--. 1 7155 31415  27089920 12月 19 03:12 mysql-community-client-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415    379072 12月 19 03:12 mysql-community-common-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415   4048564 12月 19 03:12 mysql-community-devel-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415  39677684 12月 19 03:12 mysql-community-embedded-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415 137631960 12月 19 03:12 mysql-community-embedded-devel-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415   2643576 12月 19 03:12 mysql-community-libs-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415   1761600 12月 19 03:12 mysql-community-libs-compat-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415 171445040 12月 19 03:12 mysql-community-server-5.7.29-1.el6.x86_64.rpm

-rw-r--r--. 1 7155 31415 109539700 12月 19 03:12 mysql-community-test-5.7.29-1.el6.x86_64.rpm

48304ba5e6f9fe08f3fa1abda7d326ab.png

依次安装:

mysql-community-common-5.7.29-1.el7.x86_64.rpm、

mysql-community-libs-5.7.29-1.el7.x86_64.rpm、

mysql-community-client-5.7.29-1.el7.x86_64.rpm、

mysql-community-server-5.7.29-1.el7.x86_64.rpm

安装common

[root@test01 mysql]# rpm -ivh mysql-community-common-5.7.29-1.el6.x86_64.rpm

warning: mysql-community-common-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                ########################################### [100%]

1:mysql-community-common ########################################### [100%]

安装libs

[root@test01 mysql]# rpm -ivh mysql-community-libs-5.7.29-1.el6.x86_64.rpm

warning: mysql-community-libs-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                ########################################### [100%]

1:mysql-community-libs   ########################################### [100%]

安装client

[root@test01 mysql]# rpm -ivh mysql-community-client-5.7.29-1.el6.x86_64.rpm

warning: mysql-community-client-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                ########################################### [100%]

1:mysql-community-client ########################################### [100%]

安装server

[root@test01 mysql]# rpm -ivh mysql-community-server-5.7.29-1.el6.x86_64.rpm

warning: mysql-community-server-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                ########################################### [100%]

1:mysql-community-server ########################################### [100%]

直接启动服务或初始化都会无法正常启动MySQL,错误如下

1 [root@test01 mysql]# mysqld --initialize --user=mysql2 2020-05-15T09:47:59.588585Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).3 2020-05-15T09:47:59.591022Z 0 [ERROR] --initialize specified but the data directory has files init. Aborting.4 2020-05-15T09:47:59.591066Z 0[ERROR] Aborting5

6 [root@test01 mysql]# service mysqld start7 初始化 MySQL 数据库: 2020-05-15T09:48:21.877088Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).8 2020-05-15T09:48:21.879595Z 0 [ERROR] --initialize specified but the data directory has files init. Aborting.9 2020-05-15T09:48:21.879633Z 0[ERROR] Aborting10

11 [失败]

原因就是:安装完所有的程序后,系统会自带一个数据文件,如下:

[root@test01 ~]# cd /etc

[root@test01 etc]# cat my.cnf

......

......datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

删除系统自带的/var/lib/mysql目录下的所有数据文件

1 [root@test01 mysql]# rm -rf *

查看防火墙端口,初始化MySQL

48304ba5e6f9fe08f3fa1abda7d326ab.png

[root@test01 mysql]# mysqld --initialize --user=mysql

48304ba5e6f9fe08f3fa1abda7d326ab.png

启动mysql服务

service mysqld start

设置数据库日志过期天数为14天

e51ff9ad13251f308138c7c866db5c29.png

获取mysql的root用户的初始密码

[root@localhost ~]# grep 'password' /var/log/mysqld.log

2020-01-14T01:09:01.515663Z 1 [Note] A temporary password is generated for root@localhost: vx*biwua,8/Q

[root@localhost ~]#

以获取mysql的root用户的初始密码登录数据库

[root@localhost ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.29

修改root密码

mysql> alter user 'root'@'localhost' identified by '12345678';

Query OK, 0 rows affected (0.01 sec)

mysql>

使密码即时生效

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql>

允许以root身份远程登录mysql

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>

修改mysql的字符集为utf8编辑文件/etc/my.conf,设置字符集为utf8

vi /etc/my.cnf

61cc4f8500230f3a5430faa3317c1bce.png

重起mysql服务

[root@localhost ~]# service mysqld restart

Redirecting to /bin/systemctl restart mysqld.service

[root@localhost ~]#

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值