博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL入门01-MySQL源码安装
阅读量:6914 次
发布时间:2019-06-27

本文共 5314 字,大约阅读时间需要 17 分钟。

操作系统:CentOS 6.7

MySQL版本:5.6.30

1.前期准备

首先需要CMake,可以yum直接安装:

yum install cmake

也可以官网  下载源码编译。

我这里选择了官网下载最新版本cmake-3.5.2.tar.gz。

# tar -zxvf cmake-3.5.2.tar.gz && cd cmake-3.5.2# ./configure部分输出略。-- Build files have been written to: /soft/cmake-3.5.2---------------------------------------------CMake has bootstrapped. Now run gmake. # gmake # make install

2.系统配置

添加组和用户:

groupadd mysqluseradd -g mysql mysql

vi /etc/security/limits.conf 文件末尾添加:

mysql   soft    nproc   2047mysql   hard    nproc   16384mysql   soft    nofile  1024mysql   hard    nofile  65536

3.CMake编译配置

解压源码包:

tar zxvf mysql-5.6.30.tar.gz && cd mysql-5.6.30

CMake编译配置

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ -DCOMPILATION_COMMENT='JSS for mysqltest' \ -DWITH_READLINE=ON \ -DSYSCONFDIR=/data/mysqldata/3306 \ -DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

遇到以下错误,

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:85 (MESSAGE):  Curses library not found.  Please install appropriate package,      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:128 (FIND_CURSES) cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE) CMakeLists.txt:421 (MYSQL_CHECK_EDITLINE) -- Configuring incomplete, errors occurred! See also "/soft/mysql-5.6.30/CMakeFiles/CMakeOutput.log". See also "/soft/mysql-5.6.30/CMakeFiles/CMakeError.log". [root@JY-DB mysql-5.6.30]#

yum安装提示缺失的包:

yum install ncurses-devel

重新删除配置文件:

rm -rf CMakeCache.txt

然后重新CMake工具编译:

CMake Warning:  Manually-specified variables were not used by the project:    WITH_READLINE-- Build files have been written to: /soft/mysql-5.6.30[root@JY-DB mysql-5.6.30]#

4.make && make install

[root@JY-DB mysql-5.6.30]# make && make install大量输出略。

这个时间会比较长,也跟机器性能有关。

5.后期配置和测试

5.1 打包MySQL二进制版本:

[root@JY-DB data]# tar zcvf mysql-5.6.30.tar.gz /usr/local/mysql/

5.2 修改MySQL软件所在目录拥有者:

chown -R mysql.mysql /usr/local/mysql

5.3 修改mysql用户环境变量:

vi ~/.bash_profile

export LANG=zh_CN.GB18030export PATH=/usr/local/mysql/bin:$PATH

5.4 创建数据库服务:

# mkdir -p /data/mysqldata/{3306/{data,tmp,binlog},backup,scripts}# chown -R mysql.mysql /data/mysqldata# su - mysql$ more /usr/local/mysql/support-files/my-default.cnf $ vi /data/mysqldata/3306/my.cnf

my.cnf配置文件内容如下:

[client]port = 3306socket = /data/mysqldata/3306/mysql.sock#The MySQL Server[mysqld]port = 3306user = mysqlsocket = /data/mysqldata/3306/mysql.sockpid-file = /data/mysqldata/3306/mysql.pidbasedir = /usr/local/mysqldatadir = /data/mysqldata/3306/datatmpdir = /data/mysqldata/3306/tmpopen_files_limit = 10240explicit_defaults_for_timestampsql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES#Buffermax_allowed_packet = 256Mmax_heap_table_size = 256Mnet_buffer_length = 8ksort_buffer_size = 2Mjoin_buffer_size = 4Mread_buffer_size = 2Mread_rnd_buffer_size = 16M#Loglog-bin = /data/mysqldata/3306/binlog/mysql-binbinlog_cache_size = 32Mmax_binlog_cache_size = 512Mmax_binlog_size = 512Mbinlog_format = mixedlog_output = FILElog-error = ../mysql-error.logslow_query_log = 1slow_query_log_file = ../slow_query.loggeneral_log = 0general_log_file = ../general_query.logexpire-logs-days = 14#InnoDBinnodb_data_file_path = ibdata1:2048M:autoextendinnodb_log_file_size = 256Minnodb_log_files_in_group = 3innodb_buffer_pool_size = 1024M[mysql]no-auto-rehashprompt = (\u@\h)[\d]>\_default-character-set = gbk

初始化MySQL数据库:

$ /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql

5.5 启动数据库服务:

mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

测试连接并查看MySQL进程和端口监听状态:

netstat -lnt | grep 3306ps -ef | grep bin/mysql | grep -v grep

实际操作过程如下:

[root@JY-DB ~]# su - mysql[mysql@JY-DB ~]$ mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.30-log JSS for mysqltest 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. (root@localhost)[(none)]> exit Bye [mysql@JY-DB ~]$ netstat -lnt |grep 3306 tcp 0 0 :::3306 :::* LISTEN [mysql@JY-DB ~]$ [mysql@JY-DB ~]$ ps -ef | grep bin/mysql | grep -v grep mysql 6736 1753 0 11:24 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf mysql 7202 6736 0 11:24 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysqldata/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=10240 --pid-file=/data/mysqldata/3306/mysql.pid --socket=/data/mysqldata/3306/mysql.sock --port=3306 转:http://www.cnblogs.com/jyzhao/p/5516031.html

转载于:https://www.cnblogs.com/andy6/p/5789205.html

你可能感兴趣的文章
剑指offer题目java实现
查看>>
LoaderManager使用详解(二)---了解LoaderManager
查看>>
EtherCAT对PHY有要求?
查看>>
ios应用内下载并安装另一个应用
查看>>
SQL GROUP BY 语句
查看>>
简单介绍一些HTML代码(字幕、音频和视频)
查看>>
Java——复选框:JCheckBox
查看>>
用android模拟器Genymotion定位元素
查看>>
iOS学习:UILabel和sizeWithFont方法
查看>>
“伴侣”机器人问世 宅男宅女们这下有福了!
查看>>
我的友情链接
查看>>
Android开发 - 更"聪明"的申请权限方式
查看>>
SVN配置安装
查看>>
linux基础命令 grep
查看>>
Awstats服务
查看>>
linux源地址转换(一)
查看>>
ZooKeeper客户端Curator使用一 创建连接
查看>>
图文说明虚拟机的几种网络模式
查看>>
将 instance 连接到 first_local_net - 每天5分钟玩转 OpenStack(82)
查看>>
Ubuntu屏幕截图快捷键知多少
查看>>