1、准备工作
1)mysql官网下载源码包
2)解压到安装用户目录
3)下载boost
2、安装步骤
安装mysql其实就3板斧,cmake、make、make install
1)在mysql源码的BUILD目录下执行
cmake .. \
-DCMAKE_INSTALL_PREFIX=/home/install_user \
-DWITH_BOOST=/home/install_user/mysql-5.7/boost/boost_1_59_0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_bin \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_NDBCLUSTER_STORAGE_ENGINE=0 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_DEBUG=1
2)继续执行命令
mkae && make install
并发make可执行mkae -j32 && make install
至此安装完成
3、准备配置文件my.cnf,my.cnf的权限为644,chmod 644 my.cnf,初始化
mysqld --defaults-file=/home/install_user/etc/my.cnf --initialize-insecure --user=install_user --basedir=/home/install_user/ --datadir=/home/install_user/data/data
my.cnf配置
[client]
port=5518
socket=/home/mysql5.7/bin/mysql.sock
default-character-set=utf8
[mysqld]
port=5518
socket=/home/mysql5.7/bin/mysql.sock
pid-file=/home/mysql5.7/bin/mysql.pid
basedir=/home/mysql5.7
datadir=/home/mysql5.7/data/data
tmpdir=/home/mysql5.7/data/tmp
character-set-server=utf8
log_error=/home/mysql5.7/log/mysql.err
server-id=2
log_bin=/home/mysql5.7/data/binlog
general_log_file=/home/mysql5.7/log/general_log
slow_query_log=ON
long_query_time=2
slow_query_log_file=/home/mysql5.7/log/query_log
log_queries_not_using_indexes=ON
4、启动mysql
1) 将安装目录/home/install_user/support-files/mysql.server 拷贝到 /home/bin目录下
2) 启动mysql
mysql.server start
3)mysql.server是shell脚本文件,默认会到在/etc/my.cnf查找配置文件。在mysql.server中找到/etc/my.cnf这里要修改成$basedir/etc/my.cnf。在重新启动
4、连接mysql,授权root用户,客户端可以通过ip和port连接
mysql -uroot -P5518 -S /home/install_user/bin/mysql.sock
grant all privileges on *.* to "root"@"%" identified by "root" with grant option;
flush privileges;
mysql -h10.46.178.96 -uroot -proot -P5877
另:
安装mysql客户端命令
yum install mysql