文档章节

MySQL 5.5.46源码安装

-启曙-
 -启曙-
发布于 2015/12/04 20:17
字数 765
阅读 54
收藏 0

环境信息准备

操作系统是centos 6.5 yum install gcc gcc-c++ cmake ncurses-devel

安装mysql

到搜狐镜像站( http://mirrors.sohu.com/mysql/MySQL-5.5/ )下载mysql源码

  • 解压 tar -xzvf mysql-5.5.46.tar.gz -Cbuild

  • 编译 由于使用了cmake进行编译

cd build/mysql-5.5.46
cmake . \
-DCMAKE_INSTALL_PREFIX=$HOME/local/mysql-5.5.46 \ #指定安装目录
-DWITH_INNOBASE_STORAGE_ENGINE=1 \                #安装innodb存储引擎
-DENABLED_LOCAL_INFILE=1 \                        #允许从本地导入数据
-DDEFAULT_CHARSET=utf8mb4 \                       #使用utf8mb4字符
-DDEFALUT_CHARSETS=all \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \               #安装blackhole存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \                 #安装archive存储引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_DEBUG=0

make
make install

添加配置文件

[client]
port = 14010
socket = /home/mysql/local/mysql-5.5.46/tmp/mysql.sock
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
port = 14010
socket = /home/mysql/local/mysql-5.5.46/tmp/mysql.sock
user = dove
skip-external-locking
datadir = /home/mysql/local/mysql-5.5.46/data/
log-error = /home/mysql/local/mysql-5.5.46/log/mysqld.err
pid-file = /home/mysql/local/mysql-5.5.46/bin/mysql.pid

key_buffer_size = 64M
myisam_sort_buffer_size = 30M
max_allowed_packet = 16M
table_open_cache = 4096
sort_buffer_size = 5M
join_buffer_size = 5M
read_buffer_size = 5M
read_rnd_buffer_size = 8M
bulk_insert_buffer_size = 64M
query_cache_size = 0 
query_cache_limit=1M
query_cache_min_res_unit = 2k
tmp_table_size=64M
max_heap_table_size = 128M

expire_logs_days=1

open_files_limit=1024
thread_concurrency = 16
max_connections=3000
max_connect_errors=3000
back_log = 600
table_cache = 4096
thread_cache_size = 100
thread_stack = 192K

skip-name-resolve

####log variables
server-id = 1
binlog_format=mixed
#log-slave-updates
log-bin=/home/mysql/local/mysql-5.5.46/log/mysql-bin
relay_log=/home/mysql/local/mysql-5.5.46/log/relay-bin
max_binlog_size = 100M
binlog_cache_size = 8M
max_binlog_cache_size = 640M
#binlog-ignore-db = mysql
replicate-ignore-db = mysql
expire-logs-days = 10
sync_binlog=100

##############slave config####################
#report-host=192.168.3.172
#report-port=19817
#report-user=rep
#report-password=rep

##############slave config####################

slow_query_log=1
slow_query_log_file=/home/mysql/local/mysql-5.5.46/log/slowquery.log
long_query_time=1
general_log=1
general_log_file=/home/mysql/local/mysql-5.5.46/log/general.log
#relay_log_purge=OFF

# Point the following paths to different dedicated disks
tmpdir = /home/mysql/local/mysql-5.5.46/tmp/
#log-update = /path-to-dedicated-directory/hostname

#auto_increment_increment=1s
#auto_increment_offset=asdafs

####innodb variables
#skip-innodb
innodb_data_home_dir = /home/mysql/local/mysql-5.5.46/data
innodb_data_file_path = ibdata:100M:autoextend
innodb_log_group_home_dir = /home/mysql/local/mysql-5.5.46/log
#innodb_log_arch_dir = /home/mysql/local/mysql-5.5.46/data/
innodb_buffer_pool_size = 1000M 
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 100M 
#innodb_log_buffer_size = 128M
innodb_log_buffer_size = 8M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2
#innodb_file_io_threads = 4
innodb_thread_concurrency = 40 
default-storage-engine=innodb
innodb_max_dirty_pages_pct = 50 
#innodb_lock_wait_timeout = 60
innodb_file_per_table = 1

interactive_timeout = 60
wait_timeout = 60

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 5M
write_buffer = 5M

[mysqlhotcopy]
interactive-timeout

初始化数据

mkdir data log tmp

cd ~/local/mysql-5.5.46

scripts/mysql_install_db --defaults-file=$HOME/local/mysql-5.5.46/my.cnf --user=dove  --basedir=$HOME/local/mysql-5.5.46

启动mysql

bin/mysqld_safe --defaults-file=$HOME/local/mysql-5.5.46/my.cnf --basedir=$HOME/local/mysql-5.5.46 &

登录mysql添加用户

  • 登录mysql
bin/mysql -u root -S$HOME/local/mysql-5.5.46/tmp/mysql.sock
  • 添加用户 dove
mysql> grant all privileges on *.* to 'dove'@'%' identified by 'dove_dove@201512041013' with grant option;
mysql> FLUSH PRIVILEGES;

配置启动脚本

#!/bin/sh

COMMAND="start";
HELP="no";
while getopts 'c:h' opt
do
 case $opt in
    c)COMMAND=$OPTARG;;
    h)HELP='yes';;
 esac
done

if [ $HELP = 'yes' ] || [ $COMMAND = "" ]
then
    echo ""
    echo "========================================================================="
    echo "*example: ./mysql.sh -c start                                           *"
    echo "*          -s: to start or shutdown MySql Server, default is start      *"
    echo "*              There are 2 commands as follows:                         *"
    echo "*              start: to start MySql Server                             *"
    echo "*              stop: to shutdown MySql Server                           *"
    echo "========================================================================="
    echo ""

    exit 0
fi

if [ $COMMAND == "start" ]
then
 $HOME/local/mysql-5.5.46/bin/mysqld_safe --defaults-file=$HOME/local/mysql-5.5.46/my.cnf --basedir=$HOME/local/mysql-5.5.46 --ledir=$HOME/local/mysql-5.5.46/bin >/dev/null 2>&1 &
fi

if [ $COMMAND == "stop" ]
then
 $HOME/local/mysql-5.5.46/bin/mysqladmin -h127.0.0.1 -P14010 -uroot shutdown
fi

参考信息

  • mysql安装

http://www.itokit.com/2012/0425/73648.html

http://www.itokit.com/2012/0425/73648.html

http://www.blogjava.net/kelly859/archive/2012/09/04/387005.html

http://wowking.blog.51cto.com/1638252/1037609

  • cmake使用

http://tech.uc.cn/?p=914

http://www.cppblog.com/skyscribe/archive/2009/12/14/103208.aspx

  • utf8mb4相关

https://segmentfault.com/a/1190000000616820

https://dev.mysql.com/doc/relnotes/mysql/5.5/en/news-5-5-3.html

https://mathiasbynens.be/notes/mysql-utf8mb4

© 著作权归作者所有

-启曙-
粉丝 9
博文 20
码字总数 14950
作品 0
广州
程序员
私信 提问
Centos7安装编译安装zabbix2.219及mariadb-5.5.46

mariadb-5.5.46的安装: 首先下载mariadb-5.5.46-linux-x8664.tar.gz,然后使用tar -xf mariadb-5.5.46-linux-x8664.tar.gz -C /usr/local目录下 添加数据库组 # groupadd mysql 添加数据库用......

xinrenbaodao
2017/08/18
0
0
构建LAMP环境

操作环境:CentOS 7.2 LAMP即Linux Apache Mariadb php 一、普通的yum安装构建 yum install mariadb-server httpd php php-mysql [root@localhost ~]# yum install httpd php php-mysql mar......

丁小水
2016/10/16
0
0
mysql5.7版本windows的安装

mysql5.7版本windows的安装, mysql-5.5.46-win32.msi;mysql-5.5.46-winx64.msi;mysql-5.7.12-winx64.msi 5.5的版本安装后自动调用初始化和序进行初始化工作(由MySQLInstanceConfig.exe完成...

独钓渔
2016/06/15
529
0
LANMP框架搭建——源码编译

所需要的源码包: mariadb-5.5.46-linux-x86_64.tar.gz httpd-2.4.9.tar.bz2 php-5.4.26.tar.bz2 nginx-1.8.1.tar.gz 编译mariadb: [root@centos7 ~]# yum -y remove mariadb* [root@cento......

Max_zhao
2017/03/13
0
0
CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz文档与启动时失败排查分析

CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz 提前准备好mariadb-5.5.46-linux-x86_64.tar.gz [root@localhost ~]# groupadd -r -g 306 mysql ###添加mysql用户 [root@lo......

春天的金缕
2017/06/21
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Mysql的sql_mode模式

sql_mode 是一个很容易被忽视的配置,宽松模式下可能会被输入一些非准确数据,所以生产环境下会要求为严格模式,为了保持生产环境和开发环境,测试环境一致性,我们开发环境和测试环境也要配...

贾峰uk
29分钟前
2
0
Qt程序打包发布方法(使用官方提供的windeployqt工具)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/toTheUnknown/article/details/81748179 如果使用到了Qt ...

shzwork
58分钟前
7
0
MainThreadSupport

MainThreadSupport EventBus 3.0 中的代码片段. org.greenrobot.eventbus.MainThreadSupport 定义一个接口,并给出默认实现类. 调用者可以在EventBus的构建者中替换该实现. public interface ...

马湖村第九后羿
今天
3
0
指定要使用的形状来代替文字的显示

控制手机键盘弹出的功能只能在ios上实现,安卓是实现不了的,所以安卓只能使用type类型来控制键盘类型,例如你要弹出数字键盘就使用type="number",如果要弹出电话键盘就使用type="tel",但这...

前端老手
今天
8
0
总结:Raft协议

一、Raft协议是什么? 分布式一致性算法。即解决分布式系统中各个副本数据一致性问题。 二、Raft的日志广播过程 发送日志到所有Followers(Raft中将非Leader节点称为Follower)。 Followers收...

浮躁的码农
今天
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部