@H_502_0@安装编译源码所需的工具和库
yum-yinstallgccgcc-c++ncurses-develperlopenssl-develbison@H_502_0@安装cmake(记得好像从MysqL 5.5开始需要cmake编译安装),可从https://cmake.org/download/中下载。
tarzxvfcmake-3.4.1.tar.gz cdcmake-3.4.1 ./bootstrap make&&makeinstall@H_502_0@二、创建用户及MysqL所需目录 @H_502_0@新增MysqL用户
groupadd-rMysqL useradd-r-gMysqLMysqL@H_502_0@ @H_502_0@新建MysqL所需目录
mkdir-p/usr/local/MysqL mkdir-p/data/MysqLdb@H_502_0@数据库文件目录创建可参照http://www.jb51.cc/article/p-ebhulbia-ou.html创建LVM并挂载。 @H_502_0@三、编译安装MysqL
@H_502_0@可从http://dev.mysql.com/downloads/mysql/下载MysqL源码。
tarzxvfMysqL-5.6.23.tar.gz cdMysqL-5.6.23 cmake-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL\ -DDEFAULT_CHARSET=utf8\ -DDEFAULT_COLLATION=utf8_general_ci\ -DWITH_INNOBASE_STORAGE_ENGINE=1\ -DWITH_ARCHIVE_STORAGE_ENGINE=1\ -DWITH_BLACKHOLE_STORAGE_ENGINE=1\ -DMysqL_DATADIR=/data/MysqLdb\ -DMysqL_TCP_PORT=3306\ -DENABLE_DOWNLOADS=1\ -DSYSCONFDIR=/etc\ -DWITH_SSL=system\ -DWITH_ZLIB=system\ -DWITH_LIBWRAP=0 make&&makeinstall@H_502_0@ @H_502_0@
-DCMAKE_INSTALL_PREFIX=dir_name | 设置MysqL安装目录 |
-DDEFAULT_CHARSET=charset_name | 设置服务器的字符集。缺省情况下,MysqL使用latin1的(CP1252西欧)字符集 |
-DDEFAULT_COLLATION=collation_name | 设置服务器的排序规则。 |
@H_502_0@-DWITH_INNOBASE_STORAGE_ENGINE=1@H_502_0@-DWITH_ARCHIVE_STORAGE_ENGINE=1@H_502_0@-DWITH_BLACKHOLE_STORAGE_ENGINE=1 | 存储引擎选项:MyISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。 |
-DMysqL_DATADIR=dir_name | 设置MysqL数据库文件目录 |
-DSYSCONFDIR | 设置my.cnf位置 |
cd/usr/local/MysqL chown-RMysqL:MysqL. cd/data/MysqLdb chown-RMysqL:MysqL.@H_502_0@初始化MysqL数据库
cd/usr/local/MysqL ./scripts/MysqL_install_db--user=MysqL--datadir=/data/MysqLdb@H_502_0@编辑MysqL配置文件
mv/etc/my.cnf/etc/my.cnf.bak@H_502_0@编辑my.cnf,my.cnf可在percona官网中及按照自己的情况生成。网址如下:https://tools.percona.com/wizard。
[MysqL] #CLIENT# port=3306 socket=/data/MysqLdb/MysqL.sock [MysqLd] #GENERAL# user=MysqL default-storage-engine=InnoDB socket=/data/MysqLdb/MysqL.sock pid-file=/data/MysqLdb/MysqL.pid #MyISAM# key-buffer-size=32M myisam-recover=FORCE,BACKUP #SAFETY# max-allowed-packet=16M max-connect-errors=1000000 #DATASTORAGE# datadir=/data/MysqLdb/ #BINARYLOGGING# log-bin=/data/MysqLdb/MysqL-bin expire-logs-days=14 sync-binlog=1 #REPLICATION# skip-slave-start=1 relay-log=/data/MysqLdb/relay-bin slave-net-timeout=60 #CACHESANDLIMITS# tmp-table-size=32M max-heap-table-size=32M query-cache-type=0 query-cache-size=0 max-connections=500 thread-cache-size=50 open-files-limit=65535 table-definition-cache=4096 table-open-cache=4096 #INNODB# innodb-flush-method=O_DIRECT innodb-log-files-in-group=2 innodb-log-file-size=64M innodb-flush-log-at-trx-commit=1 innodb-file-per-table=1 innodb-buffer-pool-size=592M #LOGGING# log-error=/data/MysqLdb/MysqL-error.log log-queries-not-using-indexes=1 slow-query-log=1 slow-query-log-file=/data/MysqLdb/MysqL-slow.log@H_502_0@
cpsupport-files/MysqL.server/etc/init.d/MysqLd vim/etc/profile.d/MysqL.sh PATH=/usr/local/MysqL/bin:/usr/local/MysqL/lib:$PATH exportPATH source/etc/profile.d/MysqL.sh@H_502_0@启动MysqL并增加启动项
serviceMysqLdstart chkconfigMysqLdon@H_502_0@设置MysqL登录权限
dropuser''@localhost; dropuser''@hostname; updateMysqL.usersetpassword=password('*******'); flushprivileges;@H_502_0@至此,MysqL编译安装完成。 原文链接:https://www.f2er.com/centos/381942.html