mySQL的安装过程---二进制和源码安装
安装 mysql
源码包安装
优化基础源
[root@db03 ~]# vim /etc/yum.repos.d/CentOS-Base.repo
安装依赖包
[root@db03 ~]# yum install -y cmake ncurses-devel autoconf
下载(或者上传):
wget https://downloads.mysql.com/archives/get/file/mysql-5.6.44.tar.gz
解压:
[root@db03 ~]# tar xf mysql-5.6.44.tar.gz
[root@db03 ~]# cd mysql-5.6.44
[root@db03 ~/mysql-5.6.44]# ll
total 252
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 BUILD
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 client
drwxr-xr-x 4 7161 31415 4096 Mar 15 2019 cmake
-rw-r--r-- 1 7161 31415 23415 Mar 15 2019 CMakeLists.txt
drwxr-xr-x 3 7161 31415 21 Mar 15 2019 cmd-line-utils
-rw-r--r-- 1 7161 31415 19838 Mar 15 2019 config.h.cmake
-rw-r--r-- 1 7161 31415 40929 Mar 15 2019 configure.cmake
-rw-r--r-- 1 7161 31415 17987 Mar 15 2019 COPYING
drwxr-xr-x 2 7161 31415 312 Mar 15 2019 dbug
drwxr-xr-x 2 7161 31415 80 Mar 15 2019 Docs
-rw-r--r-- 1 7161 31415 65958 Mar 15 2019 Doxyfile-perfschema
drwxr-xr-x 4 7161 31415 229 Mar 15 2019 extra
drwxr-xr-x 4 7161 31415 4096 Mar 15 2019 include
-rw-r--r-- 1 7161 31415 333 Mar 15 2019 INSTALL
drwxr-xr-x 3 7161 31415 224 Mar 15 2019 libmysql
drwxr-xr-x 3 7161 31415 204 Mar 15 2019 libmysqld
drwxr-xr-x 2 7161 31415 221 Mar 15 2019 libservices
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 man
drwxr-xr-x 10 7161 31415 305 Mar 15 2019 mysql-test
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 mysys
drwxr-xr-x 2 7161 31415 300 Mar 15 2019 mysys_ssl
drwxr-xr-x 9 7161 31415 113 Mar 15 2019 packaging
drwxr-xr-x 11 7161 31415 187 Mar 15 2019 plugin
-rw-r--r-- 1 7161 31415 2496 Mar 15 2019 README
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 regex
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 scripts
drwxr-xr-x 2 7161 31415 6 Mar 15 2019 source_downloads
drwxr-xr-x 4 7161 31415 12288 Mar 15 2019 sql
drwxr-xr-x 5 7161 31415 4096 Mar 15 2019 sql-bench
drwxr-xr-x 2 7161 31415 155 Mar 15 2019 sql-common
drwxr-xr-x 13 7161 31415 169 Mar 15 2019 storage
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 strings
drwxr-xr-x 5 7161 31415 4096 Mar 15 2019 support-files
drwxr-xr-x 2 7161 31415 4096 Mar 15 2019 tests
drwxr-xr-x 5 7161 31415 70 Mar 15 2019 unittest
-rw-r--r-- 1 7161 31415 88 Mar 15 2019 VERSION
drwxr-xr-x 3 7161 31415 298 Mar 15 2019 vio
drwxr-xr-x 2 7161 31415 32 Mar 15 2019 win
drwxr-xr-x 11 7161 31415 4096 Mar 15 2019 zlib
确定安装路径存在不存在,不存在则创建 /opt/mysql-5.6.44:
[root@db03 ~/mysql-5.6.44]# ll /opt/ -d
drwxr-xr-x. 2 root root 6 Apr 11 2018 /opt/
生成:
[root@db03 ~/mysql-5.6.44]# “注意必须在此目录里面进行生成”
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql-5.6.44 \
-DMYSQL_DATADIR=/opt/mysql-5.6.44/data \
-DMYSQL_UNIX_ADDR=/opt/mysql-5.6.44/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
#生成完成后检查
[root@db03 ~/mysql-5.6.44]# echo $?
等于 0 则没有问题
编译:
[root@db03 ~/mysql-5.6.44]# make
安装:
[root@db03 ~/mysql-5.6.44]# make install
#检查
[root@db03 ~/mysql-5.6.44]# ll /opt/mysql-5.6.44/
total 44
drwxr-xr-x 2 root root 4096 Oct 31 03:53 bin
-rw-r--r-- 1 root root 17987 Mar 15 2019 COPYING
drwxr-xr-x 3 root root 18 Oct 31 03:53 data
drwxr-xr-x 2 root root 55 Oct 31 03:53 docs
drwxr-xr-x 3 root root 4096 Oct 31 03:53 include
drwxr-xr-x 3 root root 291 Oct 31 03:53 lib
drwxr-xr-x 4 root root 30 Oct 31 03:53 man
drwxr-xr-x 10 root root 4096 Oct 31 03:53 mysql-test
-rw-r--r-- 1 root root 2496 Mar 15 2019 README
drwxr-xr-x 2 root root 30 Oct 31 03:53 scripts
drwxr-xr-x 28 root root 4096 Oct 31 03:53 share
drwxr-xr-x 4 root root 4096 Oct 31 03:53 sql-bench
drwxr-xr-x 2 root root 136 Oct 31 03:53 support-files
创建用户
[root@db03 ~/mysql-5.6.44]# useradd mysql -s /sbin/nologin -M
[root@db03 ~/mysql-5.6.44]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
拷贝启动脚本
[root@db03 ~/mysql-5.6.44]# cd /opt/mysql-5.6.44/support-files/
[root@db03 /opt/mysql-5.6.44/support-files]# cp mysql.server /etc/init.d/mysqld
[root@db03 /opt/mysql-5.6.44/support-files]# ll /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10571 Oct 31 03:57 /etc/init.d/mysqld
拷贝配置文件( 存在就覆盖,不存在则创建 )
[root@db03 /opt/mysql-5.6.44/support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
创建socket文件存放目录
[root@db03 /opt/mysql-5.6.44/support-files]# mkdir /opt/mysql-5.6.44/tmp
[root@db03 /opt/mysql-5.6.44/support-files]# ll /opt/mysql-5.6.44/tmp -d
drwxr-xr-x 2 root root 6 Oct 31 03:59 /opt/mysql-5.6.44/tmp
制作软连接
[root@db03 /opt/mysql-5.6.44/support-files]# cd /opt/mysql-5.6.44/scripts/
[root@db03 /opt/mysql-5.6.44/scripts]# ll
total 36
-rwxr-xr-x 1 root root 34558 Oct 31 03:31 mysql_install_db
[root@db03 /opt/mysql-5.6.44/scripts]# ln -s /opt/mysql-5.6.44/ /opt/mysql
[root@db03 /opt/mysql-5.6.44/scripts]# ll /opt/mysql
lrwxrwxrwx 1 root root 18 Oct 31 04:01 /opt/mysql -> /opt/mysql-5.6.44/
授权
[root@db03 /opt/mysql-5.6.44/scripts]# chown -R mysql.mysql /opt/*
初始化数据库
[root@db03 /opt/mysql-5.6.44/scripts]# ./mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
启动mysql服务
[root@db03 /opt/mysql-5.6.44/scripts]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
添加环境变量
[root@db03 /opt/mysql-5.6.44/scripts]# vim /etc/profile.d/mysql.sh
export PATH="/opt/mysql/bin:$PATH"
[root@db03 /opt/mysql-5.6.44/scripts]# source /etc/profile.d/mysql.sh
端口检查
[root@db03 /opt/mysql-5.6.44/scripts]# netstat -lntup |grep 3306
tcp6 0 0 :::3306 :::* LISTEN 25084/mysqld
启动数据库
[root@db03 /opt/mysql-5.6.44/scripts]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.44 Source distribution
Copyright (c) 2000, 2019, 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>
更改mysql启动的权限并加入systemd管理
vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
将mysql 加入systemd管理,并加入开机自启
[root@db01 ~]# vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf ---------------注意安装路径
LimitNOFILE = 5000
[root@db01 ~]# systemctl start mysqld
[root@db01 ~]# systemctl stop mysqld
[root@db01 ~]# systemctl enable mysqld
二进制安装 mysql
下载或上传软件包
wget https://downloads.mysql.com/archives/get/file/mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
解压
[root@db04 ~]# tar xf mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
[root@db04 ~]# ll
total 321404
drwxr-xr-x 13 root root 191 Oct 31 04:31 mysql-5.6.44-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 329105487 Oct 30 10:23 mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
安装依赖软件包
[root@db04 ~]# yum install -y autoconf libaio*
创建 mysql 用户
[root@db04 ~]# useradd mysql -s /sbin/nologin -M
[root@db04 ~]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
将解压后的软件包目录移动到 /opt 目录下面并更改文件名
[root@db04 ~]# mv mysql-5.6.44-linux-glibc2.12-x86_64 /opt/mysql-5.6.44
[root@db04 ~]# cd /opt/mysql-5.6.44/
[root@db04 /opt/mysql-5.6.44]# ll
total 40
drwxr-xr-x 2 root root 4096 Oct 31 04:31 bin
-rw-r--r-- 1 7161 31415 17987 Mar 15 2019 COPYING
drwxr-xr-x 3 root root 18 Oct 31 04:30 data
drwxr-xr-x 2 root root 55 Oct 31 04:30 docs
drwxr-xr-x 3 root root 4096 Oct 31 04:30 include
drwxr-xr-x 3 root root 316 Oct 31 04:31 lib
drwxr-xr-x 4 root root 30 Oct 31 04:30 man
drwxr-xr-x 10 root root 291 Oct 31 04:30 mysql-test
-rw-r--r-- 1 7161 31415 2496 Mar 15 2019 README
drwxr-xr-x 2 root root 30 Oct 31 04:30 scripts
drwxr-xr-x 28 root root 4096 Oct 31 04:31 share
drwxr-xr-x 4 root root 4096 Oct 31 04:31 sql-bench
drwxr-xr-x 2 root root 136 Oct 31 04:30 support-files
制作软连接
[root@db04 ~]# ln -s /opt/mysql-5.6.44/ /opt/mysql
[root@db04 ~]# ll /opt/mysql
lrwxrwxrwx 1 root root 18 Oct 31 04:37 /opt/mysql -> /opt/mysql-5.6.44/
拷贝启动脚本
[root@db04 /opt/mysql-5.6.44]# cd /opt/mysql-5.6.44/support-files/
[root@db04 /opt/mysql-5.6.44/support-files]# cp mysql.server /etc/init.d/mysqld
[root@db04 /opt/mysql-5.6.44/support-files]# ll /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10565 Oct 31 04:40 /etc/init.d/mysqld
拷贝配置文件
[root@db04 /opt/mysql-5.6.44/support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@db04 /opt/mysql-5.6.44/support-files]# ll /etc/my.cnf
-rw-r--r--. 1 root root 1126 Oct 31 04:41 /etc/my.cnf
初始化数据库
[root@db04 /opt/mysql-5.6.44/support-files]# cd ../scripts/
[root@db04 /opt/mysql-5.6.44/scripts]# ll
total 36
-rwxr-xr-x 1 7161 31415 34558 Mar 15 2019 mysql_install_db
[root@db04 /opt/mysql-5.6.44/scripts]# ./mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data --user=mysql
授权 mysql 目录
[root@db04 /opt/mysql-5.6.44/scripts]# chown -R mysql.mysql /opt/*
[root@db04 /opt/mysql-5.6.44/scripts]# ll /opt/
total 0
lrwxrwxrwx 1 mysql mysql 18 Oct 31 04:37 mysql -> /opt/mysql-5.6.44/
drwxr-xr-x 13 mysql mysql 223 Oct 31 04:43 mysql-5.6.44
修改 mysql 启动脚本和程序
[root@db04 /opt/mysql-5.6.44/scripts]# sed -i 's#/usr/local#/opt#g' /etc/init.d/mysqld /opt/mysql/bin/mysqld_safe
启动 mysqkl
[root@db04 /opt/mysql-5.6.44/scripts]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/opt/mysql/data/db04.err'.
SUCCESS!
添加环境变量
[root@db04 /opt/mysql-5.6.44/scripts]# vim /etc/profile.d/mysql.sh
export PATH="/opt/mysql/bin:$PATH"
[root@db04 /opt/mysql-5.6.44/scripts]# source /etc/profile.d/mysql.sh
登录mysql数据库
[root@db04 /opt/mysql-5.6.44/scripts]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.44 MySQL Community Server (GPL) Copyright (c) 2000, 2019, 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>
将mysql 加入systemd管理,并加入开机自启
[root@db01 ~]# vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf ---------------注意安装路径
LimitNOFILE = 5000 ------------------------
[root@db04 ~]# vim /etc/my.cnf basedir = /opt/mysql ----------------------更改此处
datadir = /opt/mysql/data ----------------------更改此处 ---------------------------- [root@db01 ~]# systemctl start mysqld
[root@db01 ~]# systemctl stop mysqld
[root@db01 ~]# systemctl enable mysqld
mySQL的安装过程---二进制和源码安装的更多相关文章
- 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二进制和源码安装
[MySQL]Linux下MySQL 5.5.5.6和5.7的RPM.二进制和源码安装 1.1 BLOG文档结构图 1.2 前言部分 1.2.1 导读和注意事项 各位技术爱好者,看完本文后, ...
- linux/centos下安装nginx(rpm安装和源码安装)详细步骤
Centos下安装nginx rpm包 ...
- 在CentOS 7上安装Node.js的4种方法(yum安装和源码安装)
CentOS 7上的安装方法,其中涵盖了源码安装,已编译版本安装,EPEL(Extra Packages for Enterprise Linux)安装和通过NVM(Node version mana ...
- 个人用户永久免费,可自动升级版Excel插件,使用VSTO开发,Excel催化剂安装过程详解及安装失败解决方法
因Excel催化剂用了VSTO的开发技术,并且为了最好的用户体验,用了Clickonce的布署方式(无需人工干预自动更新,让用户使用如浏览器访问网站一般,永远是最新的内容和功能).对安装过程有一定的难 ...
- Linux(CentOS)安装Node.JS和npm的两种方式(yum安装和源码安装)
yum安装 yum安装是将yum源中的rpm包下载到本地,安装这个rpm包.这个rpm包是别人编译安装好的二进制包.这种方式方便快捷,特别是不用考虑包依赖. 0.了解linux版本 通过 uname ...
- 【转】CentOS上安装 jdk:rpm安装和源码安装
1.安装 jdk-8u5-linux-x64.rpm 原文链接:http://www.cnblogs.com/xsi640/p/3756995.html 先下载最新的jdk版本 文件名:jdk-8u5 ...
- Mysql依赖库Boost的源码安装,linux下boost库的安装
boost‘准标准库’安装过程.安装的是boost_1_60_0. (1)首先去下载最新的boost代码包,网址www.boost.org. (2)进入到自己的目录,解压: bzip2 -d bo ...
- 006--linux基础rpm和yum的使用和源码安装
一.rpm相关命令介绍 1. 查看CD里面有的文件 2. 用rpm来安装一个名为vsftpd的rpm包 3. rpm -qi 软件包名 (查看软件包的详细信息) 4. rpm -ql 软件包名 (查看 ...
- 手机app传统邀请码安装与免邀请码安装区别,如何选择呢?
App 邀请机制是每个产品几乎必做的功能点,它一般以两种形式存在:一是作为常置功能用于推荐,二是作为裂变活动用于邀请. 无论以哪种形式出现,都可以归为社交分享的一种表现方式.相较于营销推广,邀请好友机 ...
随机推荐
- Docker 01 - CentOS 7 中安装 Docker 的详细步骤
目录 1 初识 Docker 1.1 Docker 原理简介 1.2 Docker 核心概念 2 安装 Docker 2.1 查看系统内核版本 2.2 更新 yum 包 2.3 安装软件包 2.4 向 ...
- xampp修改mysql 启动脚本
打开xmapp,点击mysql对应的config按钮进入my.ini文件,如图所示: 修改mysqld服务的port参数3306为你想要设置的port,如图2所示: 重新启动mysql服务即可用客户端 ...
- C语言I博客作业
|这个作业属于哪个课程 | C语言程序设计I | | ---- | ---- | |对这个作业要求在哪里 | https://edu.cnblogs.com/campus/zswxy/SE2019-2 ...
- 利用Travis CI+GitHub实现持续集成和自动部署
前言 如果你手动部署过项目,一定会深感持续集成的必要性,因为手动部署实在又繁琐又耗时,虽然部署流程基本固定,依然容易出错. 如果你很熟悉持续集成,一定会同意这样的观点:"使用它已经成为一种标 ...
- .net core 3.0 Signalr - 05 使用jwt将用户跟signalr关联
Signalr是以Group.Connect为核心来进行推送,比如,给某个组.某个连接来推送,但实际场景中,核心应该是某个组.某个人:然而一个人可以对应多个连接(浏览器多个tab页):本节就来介绍下自 ...
- AOP框架Dora.Interception 3.0 [1]: 编程体验
.NET Core正式发布之后,我为.NET Core度身定制的AOP框架Dora.Interception也升级到3.0.这个版本除了升级底层类库(.NET Standard 2.1)之外,我还对它 ...
- Python爬虫:获取JS动态内容
经过一段时间的python学习,能写出一些爬虫了.但是,遇到js动态加载的网页就犯了难.于是乎谷歌.百度,发现个好介绍http://www.jianshu.com/p/4fe8bb1ea984 主要就 ...
- 1. jQuery中的DOM操作
1)查找节点 通过jQuery选择器来完成 2)创建节点 创建元素节点:var newTd = $("<td></td>") 创建文本节点:在创建元素节点时 ...
- centos7.x 将普通用户加入sudoers中,获取sudo执行权限
centos7.x 将普通用户加入sudoers中,获取sudo执行权限 0 问题由来 你在提起兴致学习的时候,兴冲冲地往黑洞洞的文本窗口输入下一行: [pan@localhost ~]$ sud ...
- 终端-Linux命令之非交互SSH密码验证-Sshpass
Sshpass是使用SSH所谓的"交互式键盘密码身份验证"以非交互方式执行密码身份验证的工具 通俗来说就是 使用ssh密码登录 是需要在连接时手动输入密码的,没办法明文连接,如下图 ...