源码安装数据库

db03:源码安装 /opt/mysql-5.6.44

0.安装依赖包
[root@db03 ~]# yum install -y cmake ncurses-devel autoconf
1.下载安装包
[root@db03 ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.44.tar.gz
2.解压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
3.创建需要安装的路径(/opt/mysql-5.6.44)
[root@db03 mysql-5.6.44]# mkdir -p /opt
4.生成
[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

5.编译
[root@db03 mysql-5.6.44]# make
6.安装
[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 04:09 bin
-rw-r--r-- 1 root root 17987 Mar 15 2019 COPYING
drwxr-xr-x 3 root root 18 Oct 31 04:09 data
drwxr-xr-x 2 root root 55 Oct 31 04:09 docs
drwxr-xr-x 3 root root 4096 Oct 31 04:09 include
drwxr-xr-x 3 root root 291 Oct 31 04:09 lib
drwxr-xr-x 4 root root 30 Oct 31 04:09 man
drwxr-xr-x 10 root root 4096 Oct 31 04:10 mysql-test
-rw-r--r-- 1 root root 2496 Mar 15 2019 README
drwxr-xr-x 2 root root 30 Oct 31 04:09 scripts
drwxr-xr-x 28 root root 4096 Oct 31 04:10 share
drwxr-xr-x 4 root root 4096 Oct 31 04:10 sql-bench
drwxr-xr-x 2 root root 136 Oct 31 04:10 support-files
7.创建系统用户
[root@db03 mysql-5.6.44]# useradd mysql -s /sbin/nologin -M
8.拷贝启动脚本到/etc/init.d/mysqld
[root@db03 mysql-5.6.44]# cd /opt/mysql-5.6.44/support-files/
[root@db03 support-files]# ll
total 32
-rwxr-xr-x 1 root root 1153 Oct 31 03:49 binary-configure
-rw-r--r-- 1 root root 773 Mar 15 2019 magic
-rw-r--r-- 1 root root 1126 Oct 31 03:49 my-default.cnf
-rwxr-xr-x 1 root root 1061 Oct 31 03:49 mysqld_multi.server
-rwxr-xr-x 1 root root 899 Oct 31 03:49 mysql-log-rotate
-rwxr-xr-x 1 root root 10571 Oct 31 03:49 mysql.server
[root@db03 support-files]# cp mysql.server /etc/init.d/mysqld
9.拷贝配置文件到/etc/my.cnf
[root@db03 support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
10.创建建socket文件存放目录
[root@db03 support-files]# mkdir /opt/mysql-5.6.44/tmp
11.创建软连接
[root@db03 support-files]# ln -s /opt/mysql-5.6.44/ /opt/mysql
12.给mysql目录授权
[root@db03 support-files]# chown -R mysql.mysql /opt/*
13.初始化化数据库
[root@db03 support-files]# cd /opt/mysql/scripts/
[root@db03 scripts]# ./mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data

img

img

14.启动数据库
[root@db03 scripts]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/opt/mysql-5.6.44/data/db03.err'.
SUCCESS!
15.添加环境变量
[root@db03 scripts]# vim /etc/profile.d/mysql.sh
export PATH="/opt/mysql/bin:$PATH"
16.加载环境变量
[root@db03 scripts]# source /etc/profile

查看所有的环境变量

[root@db03 scripts]# echo $PATH
/opt/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
17.检查端口号
[root@db03 scripts]# netstat -lntup
tcp6 0 0 :::3306 ::😗 LISTEN 25602/mysqld

posted @ 2019-10-31 09:03  lianbingrong  阅读(291)  评论(0编辑  收藏  举报