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

[经验分享] 源码方式安装mysql 5.6.15

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-1-19 09:04:46 | 显示全部楼层 |阅读模式

MySql主从安装
1 环境介绍

操作系统:Oracle Linux Server release 6.2
2 安装软件
采用源码安装方式
1. mysql安装包:mysql-5.6.15.tar.gz
Mysql 下载地址:http://dev.mysql.com/downloads/
2.  Cmake安装包
mysql5.5以后是通过cmake来编译的
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

3 删除Oracle Linux自带的MySql
如果已经安装了Mysql其他版本,先删除
3.1 检查是否安装了MySQL
[iyunv@study1 /]# rpm -qa | grep -i mysql
mysql-libs-5.1.52-1.el6_0.1.i686
qt-mysql-4.6.2-20.el6.i686
mysql-server-5.1.52-1.el6_0.1.i686
mysql-5.1.52-1.el6_0.1.i686
perl-DBD-MySQL-4.013-3.el6.i686

3.2 使用yum来删除MySQL
[iyunv@study1 ~]# yum -y remove  mysql-server-5.1.52-1.el6_0.1.i686
[iyunv@study1 ~]# yum -y remove mysql-5.1.52-1.el6_0.1.i686
[iyunv@study1 ~]# yum -y remove mysql-libs-5.1.52-1.el6_0.1.i686
4 主服务器上安装MySql
4.1 先安装cmake
[iyunv@study1 software]# tar -zxvf cmake-2.8.4.tar.gz
[iyunv@study1 software]# cd cmake-2.8.4
[iyunv@study1 cmake-2.8.4]# ./configure
[iyunv@study1 cmake-2.8.4]# make
[iyunv@study1 cmake-2.8.4]# make install

4.2 创建mysql的安装目录及数据存放目录
[iyunv@study1 opt]# mkdir /opt/mysql        //安装mysql
[iyunv@study1 opt]# mkdir /opt/mysql/data    //存放数据
4.3 创建mysql用户及用户组
[iyunv@study1 opt]# groupadd mysql
[iyunv@study1 opt]# useradd –r –g mysql mysql
赋予数据存放目录权限:
chown mysql:mysql -R /opt/mysql/data

4.4 编译安装mysql
? 编译
[iyunv@study1 software]# tar -zxvf mysql-5.6.15.tar.gz
[iyunv@study1 software]# cd mysql-5.6.15
[iyunv@study1 mysql-5.6.15]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DSYSCONFDIR=/opt/mysql/etc \
-DMYSQL_DATADIR=/opt/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_SSL=bundled \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

参数说明:
CMAKE_INSTALL_PREFIX : MySQL安装目录
SYSCONFDIR : 配置文件目录
MYSQL_DATADIR :数据库目录
MYSQL_TCP_PORT :数据库端口
MYSQL_UNIX_ADDR :安排个目录放mysql.sock文件把,可以设置为日志存放,data存放目录等位置
WITH_EXTRA_CHARSETS : 字符
WITH_SSL       :the type of SSL
WITH_EMBEDDED_SERVER :Whether to build embedded server (默认:OFF)
ENABLED_LOCAL_INFILE :Whether to enable LOCAL for LOAD DATA INFILE(默认:OFF)  允许从本地导入数据
WITH_INNOBASE_STORAGE_ENGINE:  1

参数详细见:http://dev.mysql.com/doc/refman/ ... ration-options.html


如果发生错误查看:
。。。/mysql-5.6.15/CMakeFiles下的CMakeError.log、CMakeOutput.log文件
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# rm -f CMakeCache.txt
? 安装
[iyunv@study1 mysql-5.6.15]# make
[iyunv@study1 mysql-5.6.15]# make install

4.5 初始化数据库
[iyunv@study1 mysql]# cd /opt/mysql
[iyunv@study1 mysql]# mkdir etc
[iyunv@study1 mysql]# mkdir log
[iyunv@study1 mysql]#  chown -R mysql .
[iyunv@study1 mysql]# chgrp -R mysql .
[iyunv@study1 mysql]# scripts/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/opt/mysql/data/
Installing MySQL system tables...2014-01-23 10:18:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-23 10:18:50 20209 [Note] InnoDB: The InnoDB memory heap is disabled
2014-01-23 10:18:50 20209 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-01-23 10:18:50 20209 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-01-23 10:18:50 20209 [Note] InnoDB: Using Linux native AIO
2014-01-23 10:18:50 20209 [Note] InnoDB: Not using CPU crc32 instructions
2014-01-23 10:18:50 20209 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-01-23 10:18:50 20209 [Note] InnoDB: Completed initialization of buffer pool
2014-01-23 10:18:50 20209 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-01-23 10:18:50 20209 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-01-23 10:18:50 20209 [Note] InnoDB: Database physically writes the file full: wait...
2014-01-23 10:18:50 20209 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-01-23 10:18:53 20209 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-01-23 10:18:56 20209 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-01-23 10:18:56 20209 [Warning] InnoDB: New log files created, LSN=45781
2014-01-23 10:18:56 20209 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-01-23 10:18:56 20209 [Note] InnoDB: Doublewrite buffer created
2014-01-23 10:18:56 20209 [Note] InnoDB: 128 rollback segment(s) are active.
2014-01-23 10:18:56 20209 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-01-23 10:18:56 20209 [Note] InnoDB: Foreign key constraint system tables created
2014-01-23 10:18:56 20209 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-01-23 10:18:56 20209 [Note] InnoDB: Tablespace and datafile system tables created.
2014-01-23 10:18:56 20209 [Note] InnoDB: Waiting for purge to start
2014-01-23 10:18:56 20209 [Note] InnoDB: 5.6.15 started; log sequence number 0
2014-01-23 10:18:58 20209 [Note] Binlog end
2014-01-23 10:18:58 20209 [Note] InnoDB: FTS optimize thread exiting.
2014-01-23 10:18:58 20209 [Note] InnoDB: Starting shutdown...
2014-01-23 10:18:59 20209 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-01-23 10:18:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-23 10:19:00 20234 [Note] InnoDB: The InnoDB memory heap is disabled
2014-01-23 10:19:00 20234 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-01-23 10:19:00 20234 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-01-23 10:19:00 20234 [Note] InnoDB: Using Linux native AIO
2014-01-23 10:19:00 20234 [Note] InnoDB: Not using CPU crc32 instructions
2014-01-23 10:19:00 20234 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-01-23 10:19:00 20234 [Note] InnoDB: Completed initialization of buffer pool
2014-01-23 10:19:00 20234 [Note] InnoDB: Highest supported file format is Barracuda.
2014-01-23 10:19:00 20234 [Note] InnoDB: 128 rollback segment(s) are active.
2014-01-23 10:19:00 20234 [Note] InnoDB: Waiting for purge to start
2014-01-23 10:19:00 20234 [Note] InnoDB: 5.6.15 started; log sequence number 1625977
2014-01-23 10:19:00 20234 [Note] Binlog end
2014-01-23 10:19:00 20234 [Note] InnoDB: FTS optimize thread exiting.
2014-01-23 10:19:00 20234 [Note] InnoDB: Starting shutdown...
2014-01-23 10:19:01 20234 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /opt/mysql//bin/mysqladmin -u root password 'new-password'
  /opt/mysql//bin/mysqladmin -u root -h study1.dlt password 'new-password'

Alternatively you can run:

  /opt/mysql//bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /opt/mysql//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /opt/mysql//my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings


[iyunv@study1 mysql]# chown -R root .
[iyunv@study1 mysql]# chown -R mysql data
[iyunv@study1 mysql]#  bin/mysqld_safe --user=mysql &
[3] 20646
[iyunv@study1 mysql]# 140123 10:42:05 mysqld_safe Logging to '/opt/mysql/data/study1.dlt.err'.
140123 10:42:05 mysqld_safe Starting mysqld daemon with databases from /opt/mysql/data
4.6 配置数据库
    修改密码:
[iyunv@study1 mysql]# bin/mysqladmin -u root password 'mysql'


[iyunv@study1 mysql]# cp support-files/mysql.server /etc/init.d/
[iyunv@study1 mysql]# cp support-files/my-default.cnf  etc/my.cnf

编辑etc/my.cnf,zai [mysqld]下增加lower_case_table_names=1
设置环境:
[iyunv@study1 etc]# cd /etc
[iyunv@study1 etc]# vi profile
在文件最后增加:
PATH=/opt/mysql/bin:/opt/mysql/lib:$PATH
export PATH

4.7 手工启动数据库
[iyunv@study1 mysql]# service mysql.server status
ERROR! MySQL is not running
[iyunv@study1 mysql]# service mysql.server start
Starting MySQL.......... SUCCESS!
[iyunv@study1 mysql]# service mysql.server status
SUCCESS! MySQL running (31160)
[iyunv@study1 mysql]#
4.8 设置自动启动
[iyunv@study1 mysql]# chkconfig --level 35 mysql.server on
[iyunv@study1 mysql]# chkconfig | grep mysql
mysql.server    0:off   1:off   2:on    3:on    4:on    5:on    6:off



运维网声明 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-41005-1-1.html 上篇帖子: MySQL集群安装、负载均衡及备份恢复 下篇帖子: 编译安装MySQL实现corosync+pacemaker+drbd+mysql高可用 mysql
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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