下载

  1. 访问www.mysql.com
  2. 点击DOWNLOADS-->Community-->MySQL Community Server
  3. 选择要下载的版本,目前可选择的有:5.55.65.78.0,这里以5.7为例,所以选择的是5.7
  4. 操作系统选择Red Hat Enterprise Linux / Oracle Linux,操作系统版本选择Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit),下面列表过滤的找到Compressed TAR Archivetar压缩文件下载即可,这里选择的是mysql-5.7.25-el7-x86_64.tar.gz

将文件下载到CentOS服务器上,或者通过Windows下载后上传到CentOS服务器上。

(这里将文件放到/opt/soft/mysql-5.7.25-el7-x86_64.tar.gz

安装配置

1、添加组和用户

[root@localhost ~]: groupadd mysql
[root@localhost ~]: useradd -r -g mysql mysql

2、解压到指定位置

这里准备将mysql放到/opt/program/mysql目录中。

  1. 创建/opt/program/目录。
  2. 进入到/opt/program/目录。
  3. 解压/opt/soft/mysql-5.7.25-el7-x86_64.tar.gz文件,不指定目录的话,会解压到用户所在的目录(也就是/opt/program/)。
  4. 重新命名文件夹名为mysql
  5. 创建数据库目录data
    [root@localhost ~]: mkdir /opt/program
    [root@localhost ~]: cd /opt/program
    [root@localhost program]: tar -zxvf /opt/soft/mysql-5.7.25-el7-x86_64.tar.gz
    mysql-5.7.25-el7-x86_64/bin/myisam_ftdump
    mysql-5.7.25-el7-x86_64/bin/myisamchk
    mysql-5.7.25-el7-x86_64/bin/myisamlog
    mysql-5.7.25-el7-x86_64/bin/myisampack
    mysql-5.7.25-el7-x86_64/bin/mysql
    …………
    [root@localhost program]: mv mysql-5.7.25-el7-x86_64 mysql
    [root@localhost program]: mkdir mysql/data

3、给用户和组赋权

[root@localhost ~]: chown -R mysql:mysql /opt/program/mysql

4、初始化mysql数据库

初始化需要指定mysql程序的目录以及数据库的目录

[root@localhost ~]: /opt/program/mysql/bin/mysqld --initialize --user=mysql --basedir=/opt/program/mysql --datadir=/opt/program/mysql/data
2019-03-16T14:28:52.317678Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-03-16T14:28:54.382317Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-03-16T14:28:54.699000Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-03-16T14:28:54.772198Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d3d169f0-47f7-11e9-9ce7-000c291627c9.
2019-03-16T14:28:54.773910Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-03-16T14:28:54.775717Z 1 [Note] A temporary password is generated for root@localhost: hxwVZi*0-e3<

警告可以先不管,最后的位置是随机生成的root密码hxwVZi*0-e3<

5、配置my.cnf文件

mysql启动时,默认会查找/etc/my.cnf文件作为配置文件。

[root@localhost ~]: vi /etc/my.cnf

配置示例如下:

[mysql]
default-character-set=utf8
 
[mysqld]
lower_case_table_names=1
basedir=/opt/program/mysql
datadir=/opt/program/mysql/data
port=3306
character-set-server=utf8
max_connections=2000
innodb_buffer_pool_size=128M
log-error=/opt/program/mysql/data/error.log
pid-file=/opt/program/mysql/data/mysql.pid
socket=/opt/program/mysql/mysql.sock

6、为mysql配置环境变量

可以通过/etc/profile文件配置。

[root@localhost ~]: vi /etc/profile

打开该文件,在最末尾的位置加上

PATH=$PATH:/opt/program/mysql/bin

保存退出,再执行

[root@localhost ~]: source /etc/profile

通过# echo $PATH可以查看环境变量信息

7、制作自启动服务

第一种,将mysql.server复制到/etc/ini.d/目录下配置自启动服务

[root@localhost ~]: cp /opt/program/mysql/support-files/mysql.server /etc/ini.d/mysql
[root@localhost ~]: chmod +x /etc/ini.d/mysql
[root@localhost ~]: chkconfig --add mysql

通过# chkconfig --list查看是否添加成功

然后通过service命令控制

[root@localhost ~]: service mysql start

第二种,通过systemd制作自启动服务

[root@localhost ~]: touch /etc/systemd/system/mysql.service
[root@localhost ~]: vi /etc/systemd/system/mysql.service

配置示例如下:

[Unit]
Description=mysql service
 
[Service]
Type=forking
ExecStart=/opt/program/mysql/support-files/mysql.server start
ExecStop=/opt/program/mysql/support-files/mysql.server stop
User=mysql
 
[Install]
WantedBy=multi-user.target

然后通过systemctl命令控制即可,启动服务和启用自启动

[root@localhost ~]: systemctl start mysql.service
[root@localhost ~]: systemctl enable mysql.service

第三种,通过systemd制作自启动服务,并且通过mysql/bin/mysqld来启动,my.cnf可以自定义位置。(参照于Windows服务的启动配置) mysql.service配置示例如下:

[Unit]
Description=mysql service
 
[Service]
ExecStart=/opt/program/mysql/bin/mysqld --defaults-file=/opt/program/mysql/my.cnf --user=mysql
User=mysql
 
[Install]
WantedBy=multi-user.target

  1. 错误:error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

解决方法: 检查是否有libaio库# rpm -qa|grep libaio,如果没有则安装# yum install libaio

CentOS 7 MySql 解压版安装配置的更多相关文章

  1. MySQL解压版安装配置详解

    MySQL解压版安装起来比较简单,步骤相对较少.下面我们就来详细介绍一下如何在windows操作系统上安装解压班的MySQL. 1.下载解压版MySQL,地址:http://downloads.mys ...

  2. MySQL解压版安装配置

    官网下载地址:http://dev.mysql.com/downloads/windows/installer/ (可以选择解压版zip下载,也可以选择msi安装版.) 解压zip版配置: 1. 下载 ...

  3. MySQL踩坑及MySQL解压版安装

    MySQL默认当前时间: MySQL5.5版本以下是不支持:datetime default now() 的,只能写成 timestamp default now() ; 而MySQL5.6以上是支持 ...

  4. MySQL Server 5.6 解压版安装配置

    MySQL解压版下载地址为: http://dev.mysql.com/downloads/mysql/5.6.html#downloads 安装及配置步骤: ①将MySQL的zip包解压到路径C:\ ...

  5. mysql 5.7.21 解压版安装配置方法图文教程

    引用:https://www.jb51.net/article/140951.htm 1.首先,你要下载MySQL解压版,下载地址,图解: 2.解压安装包,根据自己的喜好选择路径,我选择的路径是C:\ ...

  6. 【Linux】MySQL解压版安装及允许远程访问

    安装环境/工具 1.Linux( centOS 版) 2.mysql-5.6.31-linux-glibc2.5-x86_64.tar 安装步骤 1.下载mysql解压版(mysql-5.6.31-l ...

  7. windows下MySQL解压版安装

    MySQL的安装 一.前期准备 获取MySQL解压版安装包(本文使用的是 [mysql-5.7.28-winx64.zip]版本) 获取方式: 通过官网下载,官方下载地址:“https://dev.m ...

  8. mysql解压版安装

    1.下载MySQL解压版(32位) http://dev.mysql.com/downloads/mysql/

  9. win10 安装 mysql解压版安装步骤

    参考资料:win 10 安装 mysql 5.7 网址:http://blog.sina.com.cn/s/blog_5f39af320102wbk0.html 本文参考上面的网址的教程,感谢作者分享 ...

随机推荐

  1. Java的Random类详解

    Random类专门用于生成一个伪随机数,它有两个构造器:一个构造器使用默认的种子(以当前时间作为种子),另一个构造器需要程序员显示传入一个long型整数的种子. Random类比Math类的rando ...

  2. Go语言strings包

    目录 strings包实现了用于操作字符的简单函数. func EqualFold 判断两个utf-8编码字符串(将unicode大写.小写.标题三种格式字符视为相同)是否相同. func Equal ...

  3. #Java学习之路——基础阶段二(第三篇)

    我的学习阶段是跟着CZBK黑马的双源课程,学习目标以及博客是为了审查自己的学习情况,毕竟看一遍,敲一遍,和自己归纳总结一遍有着很大的区别,在此期间我会参杂Java疯狂讲义(第四版)里面的内容. 前言: ...

  4. 处理SQL Server中的重复行

    如果表中的数据需要基于行中的多个值具有唯一约束,则适合的解决方案将是复合健. 复合主键 使用SQL Server语法创建符合主键非常简单. create table my_parts ( id_par ...

  5. 利用GitLab webhook来实现触发Jenkins自动操作

    本文针对如何设置GitLab以及Jenkins,实现每次GitLab上有提交事件的时候,都能触发Jenkins执行相应的操作,主要分为以下几个步骤: 1.新建GitLab测试用例 进入个人GitLab ...

  6. Linux用户和权限管理看了你就会用啦

    前言 只有光头才能变强 回顾前面: 看完这篇Linux基本的操作就会了 没想到上一篇能在知乎获得千赞呀,Linux也快期末考试了,也有半个月没有写文章了.这篇主要将Linux下的用户和权限知识点再整理 ...

  7. Asp.Net Core 轻松学-被低估的过滤器

    前言     过滤器,从我们开始开发 Asp.Net 应用程序开始,就一直伴随在我们左右:Asp.Net Core 提供多种类型的过滤器,以满足多种多样的业务应用场景:并且在 Asp.Net Core ...

  8. jquery快速入门(四)

    jQuery 遍历 向上遍历 DOM 树 parent() parent() 方法返回被选元素的直接父元素.该方法只会向上一级对 DOM 树进行遍历. parents() parents() 方法返回 ...

  9. 【大数据安全】CDH集群禁用Kerberos

    在调试Kerberos的时候可能会有需要禁用的场景.以下是各组件禁用Kerberos的相关配置. 环境 CDH版本:5.11.2 Linux版本:7.4.1708 Docker版本:Docker ve ...

  10. 第64章 学习 - Identity Server 4 中文文档(v1.0.0)

    以下是一些在线,远程和课堂培训选项,以了解有关ASP.NET Core Identity和IdentityServer4的更多信息. 64.1 现代应用程序的身份和访问控制(使用ASP.NET Cor ...