一、环境说明:

[root@beanvm ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.2 (Santiago)

[root@beanvm ~]# uname -a

Linux beanvm 2.6.32-220.el6.i686 #1 SMP Wed Nov 9 08:02:18 EST 2011 i686 i686 i386 GNU/Linux

二、准备工作与系统配置

1.下载安装包

这里下载的是较新的MySQL 5.6.16版本,更新迭代的太快了,文件为:mysql-5.6.16.tar.gz

2. 安装编译必须的包

[root@beanvm ~]# rpm -ivh bison-devel-2.4.1-5.el6.i686.rpm

warning: bison-devel-2.4.1-5.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

Preparing...                ########################################### [100%]

1:bison-devel            ########################################### [100%]

[root@beanvm ~]# rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm

warning: ncurses-devel-5.7-3.20090208.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

Preparing...                ########################################### [100%]

1:ncurses-devel          ########################################### [100%]

个人经验上面两个包是比较容易缺失,像gcc,make,cmake则是必备的了,也建议检查一下:

[root@beanvm ~]# rpm -qa |grep gcc-c++

gcc-c++-4.4.6-3.el6.i686

[root@beanvm ~]# rpm -qa |grep make

imake-1.0.2-11.el6.i686

automake-1.11.1-1.2.el6.noarch

cmake-2.6.4-5.el6.i686

make-3.81-19.el6.i686

3.创建MySQL用户和组

[root@beanvm ~]# groupadd mysql

[root@beanvm ~]# useradd -g mysql mysql

[root@beanvm ~]# passwd mysql

4.配置环境变量

[root@beanvm ~]# su – mysql

在.bash_profile文件中为PATH变量追加mysql路径:

export PATH=/sbin:$HOME/bin:/usr/local/mysql/bin:$PATH

三、安装MySQL

解压安装包:

[root@beanvm ~]# tar -xvf mysql-5.6.16.tar.gz

[root@beanvm ~]# cd mysql-5.6.16

编译脚本如下:

cmake \

# MySQL根目录

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

# 数据文件目录

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

make && make install

基本上安装的选项还是一目了然的,更多的选项示意参见:

编译时间是机器而定,我的有20多分钟的样子。

安装完成后要给根目录指定为mysql用户和组,也可以在这时候进行mysql用户和组的创建工作:

[root@beanvm ~]# chown -R mysql:mysql /usr/local/mysql

安装完成的MySQL根目录如下:

[root@beanvm ~]# ls -l /usr/local/mysql/

total 164

drwxr-xr-x.  2 mysql mysql  4096 Feb 15 14:40 bin

-rw-r--r--.  1 mysql mysql 17987 Jan 14 23:38 COPYING

drwxr-xr-x.  6 mysql mysql  4096 Feb 18 16:32 data

drwxr-xr-x.  2 mysql mysql  4096 Feb 15 14:39 docs

drwxr-xr-x.  3 mysql mysql  4096 Feb 15 14:39 include

-rw-r--r--.  1 mysql mysql 88109 Jan 14 23:38 INSTALL-BINARY

drwxr-xr-x.  3 mysql mysql  4096 Feb 15 14:39 lib

drwxr-xr-x.  4 mysql mysql  4096 Feb 15 14:40 man

-rw-r--r--.  1 mysql mysql   943 Feb 15 14:56 my.cnf

-rw-r--r--.  1 mysql mysql   943 Feb 18 16:26 my-new.cnf

drwxr-xr-x. 10 mysql mysql  4096 Feb 15 14:40 mysql-test

-rw-r--r--.  1 mysql mysql  2496 Jan 14 23:38 README

drwxr-xr-x.  2 mysql mysql  4096 Feb 15 14:40 scripts

drwxr-xr-x. 28 mysql mysql  4096 Feb 15 14:40 share

drwxr-xr-x.  4 mysql mysql  4096 Feb 15 14:40 sql-bench

drwxr-xr-x.  3 mysql mysql  4096 Feb 15 14:40 support-files

可以看到已经创建一个默认的配置文件my.cnf。

四、MySQL初始化

执行初始化脚本来创建数据库:

[root@beanvm ~]# cd /usr/local/mysql/scripts/

[root@beanvm scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

创建MySQL服务并启动:

[root@beanvm ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

[root@beanvm ~]# service mysql start

Starting MySQL.. SUCCESS!

接下来就是配置数据库了,在新版的MySQL安装过程中提供了一个脚本用于自动完成数据库使用前的配置工作,这个脚本位于/usr/local/mysql/bin/mysql_secure_installation,它会完成以下任务:

1.指定root用户密码(默认是没有密码的)

2.删除匿名用户

3.设置root用户的远程访问(对应的要在防火墙中开启3306端口)

4.是否删除测试数据库

5.重载权限表

这里建议使用这个脚本,执行过程如下:

[mysql@beanvm ~]$ /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] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

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] n

... skipping.

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...

当然也可以手动完成这些操作:

[mysql@beanvm ~]$ mysqladmin -u root password 'new-password'

[mysql@beanvm ~]$ mysqladmin -u root -h beanvm password 'new-password'

[mysql@beanvm ~]$ mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 19

Server version: 5.6.16 Source distribution

Copyright (c) 2000, 2014, 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> delete from mysql.user where user='';

Query OK, 2 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypasswd' WITH GRANT OPTION;

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

redhat mysql编译安装_RHEL6.2编译安装MySQL 5.6.16过程分享相关推荐

  1. mysql innodb表损坏_MySQL数据库INNODB表损坏修复处理过程分享

    ##状况描述 突然收到MySQL报警,从库的数据库挂了,一直在不停的重启,打开错误日志,发现有张表坏了.innodb表损坏不能通过repair table 等修复myisam的命令操作.现在记录下解决 ...

  2. apache 编译安装php mysql_编译安装APACHE+PHP+MYSQL

    adminjun qq:279872 网络技术研究会群:8070045 中国linux公社论坛群:4478487 其实这是我用RouterOS和redhat linux进行pppoe服务器的配置及在r ...

  3. linux mysql编译安装mysql_【MySQL安装】Linux下安装MySQL(预编译)

    预编译方式安装MySQL 一.环境说明 操作系统:Redhat Linux 7.2 MySQL版本:5.7 安装介质:mysql-5.7.25-linux-glibc2.12-x86_64.tar.g ...

  4. redhat6.3 安装 mysql_redhat6.3X64/linux 安装多个mysql(编译安装方法)

    前言: 以下7点是完整安装步骤,各步骤可以根据现有环境跳过.如果之前有装过mysql,无需卸载. 本文所使用的环境是:redhat企业版6.3x64,mysql5.5.29,bison-2.5,cma ...

  5. redhat 6.5 【源码编译安装 mysql-5.5.47】

    操作系统:Redhat Enterprise Linux 6.5 一. 创建用户.目录和修改权限 [root@xuegod64 ~]#mkdir -p /usr/local/mysql/data[ro ...

  6. mysql5.5.8编译安装_Mysql应用linux下mysql 5.5.8 源码编译安装

    <MysqL应用linux下MysqL 5.5.8 源码编译安装>要点: 本文介绍了MysqL应用linux下MysqL 5.5.8 源码编译安装,希望对您有用.如果有疑问,可以联系我们. ...

  7. mysql 5.7 编译_Mysql5.7版本编译安装及配置

    配置yum安装方式 1.配置本地yum源 1 vim /etc/yum.repos.d/rhel-source.repo2 [rhel-source] 3 name=Red Hat Enterpris ...

  8. mysql 数据库安装命令_教你MySQL数据库的编译安装以及命令详解(5.7版本)

    一.安装MySQL所需的环境依赖包 [root@localhost opt]# yum -y install gcc gcc-c++ make ncurses ncurses-devel bison ...

  9. Redhat EL 5.3上安装Cacti(4)- 编译安装rrdtool及安装配置snmp

    Redhat EL 5.3上安装Cacti(4)- 编译安装rrdtool及安装配置snmp Linux下安装Cacti实现网络监控 由于博客字符8万限制,所以分开5部分上传! 请看Redhat EL ...

最新文章

  1. Hibernate一对一关联映射配置
  2. PowerDesigner的Table视图同时显示Code和Name的方法[转发]
  3. UGUI与NGUI的区别汇总
  4. FreeBSD从零开始---安装后配置(三)
  5. BZOJ3130: [Sdoi2013]费用流[最大流 实数二分]
  6. php+jquery实现图片上传预览_和拖动位置值,PHP教程:thinkphp jquery实现图片上传和预览效果...
  7. [深度学习-原理]浅谈Attention Model
  8. springboot的细节挖掘(ActiveMq集成)
  9. Android中SurfaceView用法示例
  10. network reactnative_Chrome 调试 react-native 通过Network面板查看网络请求
  11. iMazing六大主要功能介绍
  12. telink泰凌微 8266 8250 8258IO中断唤醒睡眠
  13. Rpg maker mv角色扮演游戏制作大师简介
  14. BlackBerry7290软件安装——电子书阅读Mobipocket
  15. 1112day10:考前复习50题:断言
  16. c语言 位赋值,【c语言】位段赋值的例子
  17. 清除linux挖矿木马[crypto]的过程
  18. 数据分析——EXCEL可视化
  19. Mac python2.7创作mid音乐文件
  20. mac电脑真正好用且实用的软件(不断积累)

热门文章

  1. php如何加载ffmpeg库,安装php扩展 ffmpeg-php
  2. react中setState有三种用法
  3. nginx生成ssl证书
  4. 关于angular2更新时机的一些发现
  5. ionic4监听返回事件 AppMinimize navController
  6. c语言模板程序,模板模式 (C语言实现)
  7. containerd项目正式从CNCF毕业
  8. 如何在vscode中使用GitLab
  9. java获取浏览器版本号
  10. Oracle Study--Oracle RAC CacheFusion(MindMap)