设为首页 收藏本站
查看: 484|回复: 0

[经验分享] MySQL-5.6.29源码编译安装记录

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-4-11 09:15:17 | 显示全部楼层 |阅读模式
一、安装环境1. 操作系统:CentOS 6.7 x86_64# yum install make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel perl   
2. cmake采用yum方式已安装,不需要再安装。
3. MySQL版本:mysql-5.6.29.tar.gz4. 同样安装方式也适用于mysql-5.5.x.tar.gz
二、安装mysql-5.6.29.tar.gz1. 下载编译版本mysql安装tar zxvf mysql-5.6.29.tar.gz   
cd mysql-5.6.29   
patch -p1 < ../mysql-openssl.patch   
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_DEBUG=0     
make && make install
注:重新编驻译采用如下方式,ssl方式不需要采用,可以删除掉相关参数。
make clean   
rm -f CMakeCache.txt

2. 准备mysql用户groupadd mysql   
useradd -g mysql -M -s /sbin/nologin mysql

3. 初始化mysql,数据库位置采用默认位置chown -R mysql:mysql /usr/local/mysql   
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

4. mysql服务配置cd /usr/local/mysql   
cp support-files/my-medium.cnf /etc/my.cnf     
cp support-files/mysql.server  /etc/rc.d/init.d/mysqld   
chkconfig --add mysqld   
chkconfig mysqld on

5. 配置Mysql命令链接ln -sf /usr/local/mysql/bin/mysql /usr/bin/mysql   
ln -sf /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump   
ln -sf /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk   
ln -sf /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe

或通过加入环境变量中解决。# vi /etc/profile   
export PATH=/usr/local/mysql/bin/:$PATH   
# source /etc/profile

6. 配置其它ln -sv /usr/local/mysql/include  /usr/include/mysql   
echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf   
ldconfig

7. Mysql配置文件vi /etc/my.cnf
[client]   
port        = 3306   
socket      = /tmp/mysql.sock
# The MySQL server   
[mysqld]   
port        = 3306   
socket      = /tmp/mysql.sock   
datadir = /usr/local/mysql/data   
skip-external-locking   
max_connections = 1000   
key_buffer_size = 16M   
max_allowed_packet = 1M   
table_open_cache = 64   
sort_buffer_size = 512K   
net_buffer_length = 8K   
read_buffer_size = 256K   
read_rnd_buffer_size = 512K   
myisam_sort_buffer_size = 8M
#skip-networking
log-bin=mysql-bin   
binlog_format=mixed   
server-id   = 1
innodb_data_home_dir = /usr/local/mysql/data   
innodb_data_file_path = ibdata1:10M:autoextend   
innodb_log_group_home_dir = /usr/local/mysql/data   
innodb_buffer_pool_size = 16M   
innodb_additional_mem_pool_size = 2M   
innodb_log_file_size = 5M   
innodb_log_buffer_size = 8M   
innodb_flush_log_at_trx_commit = 1   
innodb_lock_wait_timeout = 50
[mysqldump]   
quick   
max_allowed_packet = 16M
[mysql]   
no-auto-rehash
[myisamchk]   
key_buffer_size = 20M   
sort_buffer_size = 20M   
read_buffer = 2M   
write_buffer = 2M
[mysqlhotcopy]   
interactive-timeout   
expire_logs_days = 10
8. 启动mysqlservice mysqld start

9. 修改管理员密码并测试# /usr/local/mysql/bin/mysqladmin -u root password 'admin' #设置管理员密码   
# /usr/local/mysql/bin/mysql -u root -p   #测试密码输入

10. 配置mysql帐号安全[iyunv@test ~]# /usr/local/mysql/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL   
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current   
password for the root user.  If you've just installed MySQL, and   
you haven't set the root password yet, the password will be blank,   
so you should just press enter here.
Enter current password for root (enter for none):   
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL   
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n   
... skipping.
By default, a MySQL installation has an anonymous user, allowing anyone   
to log into MySQL without having to have a user account created for   
them.  This is intended only for testing, and to make the installation   
go a bit smoother.  You should remove them before moving into a   
production environment.
Remove anonymous users? [Y/n] y   
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This   
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n   
... skipping.
By default, MySQL comes with a database named 'test' that anyone can   
access.  This is also intended only for testing, and should be removed   
before moving into a production environment.
Remove test database and access to it? [Y/n] y   
- Dropping test database...   
... Success!   
- Removing privileges on test database...   
... Success!
Reloading the privilege tables will ensure that all changes made so far   
will take effect immediately.
Reload privilege tables now? [Y/n] y   
... Success!
All done!  If you've completed all of the above steps, your MySQL   
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
登录测试:[iyunv@test data]# mysql -uroot -p   
Enter password:     
Welcome to the MySQL monitor.  Commands end with ; or \g.   
Your MySQL connection id is 9   
Server version: 5.6.29-log Source distribution
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.
mysql> \s   
--------------   
mysql  Ver 14.14 Distrib 5.6.29, for Linux (x86_64) using  EditLine wrapper
Connection id:          9   
Current database:   
Current user:           root@localhost   
SSL:                    Not in use   
Current pager:          stdout   
Using outfile:          ''   
Using delimiter:        ;   
Server version:         5.6.29-log Source distribution   
Protocol version:       10   
Connection:             Localhost via UNIX socket   
Server characterset:    utf8   
Db     characterset:    utf8   
Client characterset:    utf8   
Conn.  characterset:    utf8   
UNIX socket:            /tmp/mysql.sock   
Uptime:                 9 min 36 sec
Threads: 1  Questions: 29  Slow queries: 0  Opens: 71  Flush tables: 1  Open tables: 64  Queries per second avg: 0.050   
--------------
mysql>
安装完毕。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-202411-1-1.html 上篇帖子: 查看MySQL版本的四种方法 下篇帖子: MySQL5.6.29的安装 记录
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表