MySQL安装

1.0安装Cmake

[root@Web_1 ~]# cd /opt/src/
[root@Web_1 src]# wget https://cmake.org/files/v2.8/cmake-2.8.12.tar.gz
–2016-08-10 18:24:39– https://cmake.org/files/v2.8/cmake-2.8.12.tar.gz
Resolving cmake.org… 66.194.253.19
Connecting to cmake.org|66.194.253.19|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 6064138 (5.8M) [application/x-gzip]
Saving to: “cmake-2.8.12.tar.gz”

100%[=====================================================================================================>] 6,064,138 120K/s in 61s

2016-08-10 18:25:42 (97.0 KB/s) - “cmake-2.8.12.tar.gz” saved [6064138/6064138]

[root@Web_1 src]# ls cmake-2.8.12.tar.gz
cmake-2.8.12.tar.gz
[root@Web_1 src]# tar zxf cmake-2.8.12.tar.gz
[root@Web_1 src]# cd cmake-2.8.12
编译安装Cmake

[root@Web_1 cmake-2.8.12]# ./configure –prefix=/opt/cmake/ && gmake && gmake install
[root@Web_1 cmake-2.8.12]# ln -s /usr/local/cmake/bin/* /usr/bin/

2.0安装MySQL

添加程序用户

[root@Web_1 cmake-2.8.12]# useradd -r -M -s /sbin/nologin mysql
[root@Web_1 cmake-2.8.12]# id mysql
uid=497(mysql) gid=497(mysql) groups=497(mysql)

编译安装MySQL

[root@Web_1 src]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.32.tar.gz
–2016-08-10 18:34:22– http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.32.tar.gz
Resolving cdn.mysql.com… 104.98.249.106
Connecting to cdn.mysql.com|104.98.249.106|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://120.52.72.22:80/cdn.mysql.com/c3pr90ntc0td//Downloads/MySQL-5.6/mysql-5.6.32.tar.gz [following]
–2016-08-10 18:34:22– http://120.52.72.22/cdn.mysql.com/c3pr90ntc0td//Downloads/MySQL-5.6/mysql-5.6.32.tar.gz
Connecting to 120.52.72.22:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 32095208 (31M) [application/x-tar-gz]
Saving to: “mysql-5.6.32.tar.gz”

100%[=====================================================================================================>] 32,095,208 8.20M/s in 3.7s

2016-08-10 18:34:26 (8.33 MB/s) - “mysql-5.6.32.tar.gz” saved [32095208/32095208]

[root@Web_1 src]# ls mysql-5.6.32.tar.gz
mysql-5.6.32.tar.gz
[root@Web_1 src]# tar zxf mysql-5.6.32.tar.gz
[root@Web_1 src]# cd mysql-5.6.32
[root@Web_1 mysql-5.6.32]# pwd
/opt/src/mysql-5.6.32

[root@Web_1 mysql-5.6.32]# cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all

make && make install

– Configuring done
– Generating done
CMake Warning:
Manually-specified variables were not used by the project:

WITH_MEMORY_STORAGE_ENGINEWITH_READLINE

– Build files have been written to: /opt/src/mysql-5.6.32
[root@Web_1 mysql-5.6.32]# make && make install #make安装
编译参数讲解

# -DCMAKE_INSTALL_PREFIX=/opt/mysql                \    #安装路径

-DMYSQL_DATADIR=/opt/mysql/data \ #数据文件存放位置

-DSYSCONFDIR=/etc \ #my.cnf路径

-DWITH_MYISAM_STORAGE_ENGINE=1 \ #支持MyIASM引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #支持InnoDB引擎

-DWITH_MEMORY_STORAGE_ENGINE=1 \ #支持Memory引擎

-DWITH_READLINE=1 \ #快捷键功能(我没用过)

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ #连接数据库socket路径

-DMYSQL_TCP_PORT=3306 \ #端口

-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据

-DWITH_PARTITION_STORAGE_ENGINE=1 \ #安装支持数据库分区

-DEXTRA_CHARSETS=all \ #安装所有的字符集

-DDEFAULT_CHARSET=utf8 \ #默认字符

建立MySQL配置文件

[root@Web_1 mysql-5.6.32]# cp support-files/my-default.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf’? y

初始化数据库

[root@Web_1 mysql-5.6.32]# /opt/mysql/scripts/mysql_install_db –user=mysql –basedir=/opt/mysql/ –datadir=/data/mysql/data

2016-08-10 19:06:50 5630 [Note] InnoDB: FTS optimize thread exiting.
2016-08-10 19:06:50 5630 [Note] InnoDB: Starting shutdown…
2016-08-10 19:06:52 5630 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

输出大致如上内容,则没问题
设置环境变量

[root@Web_1 mysql-5.6.32]# echo “PATH=$PATH:/opt/mysql/bin/“ >> /etc/profile
[root@Web_1 mysql-5.6.32]# . /etc/profile
[root@Web_1 mysql-5.6.32]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/mysql/bin/

添加服务脚本

[root@Web_1 mysql-5.6.32]# cp support-files/mysql.server /etc/init.d/mysqld
[root@Web_1 mysql-5.6.32]# chmod +x !$
chmod +x /etc/init.d/mysqld
[root@Web_1 mysql-5.6.32]# chkconfig –add mysqld
[root@Web_1 mysql-5.6.32]# chkconfig mysqld on
[root@Web_1 mysql-5.6.32]# service mysqld start
Starting MySQL. [ OK ]

登录测试

[root@Web_1 mysql-5.6.32]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 Source distribution

Copyright (c) 2000, 2016, 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> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test |
+——————–+
4 rows in set (0.01 sec)

mysql>
 

版权声明:
作者:WangGaoli
链接:https://wanggaoli.com/2868.html
来源:王高利的个人博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>