运维开发网

MySQL编译安装

运维开发网 https://www.qedev.com 2020-09-14 12:13 出处:51CTO 作者:唐勇007
一、MySQL5.6.36安装前准备(1)克隆一个模板机器(使用centos6),克隆完做快照(2)IP10.0.0.52主机名db02(3)iptablesselinux(4)下载好5.6.36(5)安装依赖包yuminstall-yncurses-devellibaio-devel(6)安装cmakeyuminstallcmake–y(7)创建用户useradd-s/sbin/nologin-

一、MySQL5.6.36安装前准备

(1)克隆一个模板机器(使用centos6),克隆完做快照

(2)IP 10.0.0.52 主机名db02

(3)iptables seLinux

(4)下载好5.6.36

(5)安装依赖包

yum install -y ncurses-devel libaio-devel

(6)安装cmake

yum install cmake –y

(7)创建用户

useradd -s /sbin/nologin -M mysql

id mysql

二、MySQL下载安装

(0)创建软件下载目录:

mkdir -p /server/tools

cd /server/tools/

(1)下载并上传到/server/tools

https://www.mysql.com/downloads/

社区版MySQL Community Server

5.6 5.6.3x 5.6.34 5.6.36 5.6.38

发布超过6-12的版本

5.7 5.7.17以后

(2)解压:

cd /server/tools

tar xf mysql-5.6.36.tar.gz

(3)安装:

cd mysql-5.6.36

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \

-DMYSQL_DATADIR=/application/mysql-5.6.36/data \

-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/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

make && make install

三、配置并启动

(1)制作软连接:

ln -s /application/mysql-5.6.36/ /application/mysql

(2)拷贝配置文件到/etc:

cp support-files/my*.cnf /etc/my.cnf

(3)初始化数据库:

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql

(4)创建关键目录并设置权限:

mkdir -p /application/mysql/tmp

chown -R mysql.mysql /application/mysql/

(5)复制启动脚本到/etc/init.d/mysqld

cp support-files/mysql.server /etc/init.d/mysqld

(6)启动数据库

/etc/init.d/mysqld start

netstat -lntup|grep 330

(7)配置环境变量

echo 'PATH=/application/mysql/bin/:$PATH' >>/etc/profile

tail -1 /etc/profile

source /etc/profile

echo $PATH

mysql

select user,host,password from mysql.user;

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号