centos6 rpm安装mysql_CentOS6离线使用rpm安装mysql5.7

声明

本文记录了自己完整安装的过程,其中参考了官网还有互联网一些文章。

软件清单

CentOS 6 -64

MySQL5.7.20

MySQL下载

有很多小伙伴不知道官网上如何下载Mysql

首先要下载MySQL Community Server 根据系统选择合适的即可

对于咱们的CentOS 6 你是无法找到的,因为它本身是属于RedHat的,所以找到对应的即可。

我这里是64位的服务器,所以我直接给出下载的连接 并选择合适你机器的版本

我遇到了浏览器下载会卡主现象,我建议用某雷下载

安装

首先系统要卸载干净Mysql,具体步骤,这里不再讲解。我们只说安装。

下载好的包 mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar 上传至服务器到目录如 /root

解压

$ tar -xvf mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar

安装顺序 顺序不对亦会有提示无须担心, --nosignature不检查签名

$ rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm --nosignature

$ rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm --nosignature

$ rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm --nosignature

$ rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm --nosignature

$ rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm --nosignature

安装包作用

mysql-devel 开发用到的库以及包含文件

mysql mysql 客户端

mysql-server 数据库服务器

删除安装包安装后 *.rpm就对我们无用了

$ sudo rm -rf mysql*.rpm

�* 检查是否安装 输出则代表安装成功

$ rpm -qa| grep mysql

mysql-community-devel-5.7.20-1.el6.x86_64

mysql-community-common-5.7.20-1.el6.x86_64

mysql-community-server-5.7.20-1.el6.x86_64

mysql-community-client-5.7.20-1.el6.x86_64

mysql-community-libs-5.7.20-1.el6.x86_64

再次检查

$ rpm -q mysql-community-server-5.7.20-1.el6.x86_64

mysql-community-server-5.7.20-1.el6.x86_64

若你是root用户

$ vim /etc/my.cnf

配置如下

[mysqld]

user=mysql

启动

$ cd /etc/init.d

$ service mysqld start

或许会提示这个错误

[ERROR] --initialize specified but the data directory has files in it. Aborting.

$ cd /var/lib

$ mv mysql mysql.bak

$ cd /etc/init.d

$ service mysqld start

Initializing MySQL database: [ OK ]

Starting mysqld: [ OK ]

验证服务运行方式一

$service mysqld status

mysqld (pid xxxxx) is running...mysqld (pid xxxxx) is running...

验证服务运行方式二

ps -ef | grep -i mysql

root 27698 1 0 14:55 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql

mysql 27906 27698 0 14:55 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

root 29144 28578 0 15:05 pts/3 00:00:00 grep -i mysql

�到此处MySQL完成安装并且Server已经启动

�* 设置root密码

有资料显示在/root/.mysql_secret 存有root密码,但是我这里找不到,我们使用绕过权限验证去修改具体步骤如下

$ service mysqld stop

$ vim /etc/

$ mysqld_safe --skip-grant-tables

我这里Shell被占用,重新打开一个,这个不要关

在新的Shell中执行

$mysql

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

Your MySQL connection id is 4

Server version: 5.7.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> use mysql

mysql>update mysql.user set authentication_string=password('root') where user='root' ;

此时重新启动mysqld,登录

$service mysqld restart

$mysql -uroot -proot

全文完

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值