CMAKE方式编译安装Mysql5.5

1、源码cmake方式编译安装MySQL5.5.32

安装前先安装:

yum install ncurses-devel -y

1.1 下载Mysql和cmake安装包:

wgethttp://wwwNaNake.org/files/v2.8/cmake-2.8.8.tar.gz

1.2 查看系统环境

cat/etc/redhat-release

uname-r

uname-m

1.3 安装cmake包

tarzxf cmake-2.8.8.tar.gz

cdcmake-2.8.8

./configure

gmake

gmakeinstall

cd ../

1.4 开始安装mysql

1.4.1 创建用户和组

groupaddmysql

useraddmysql -s /sbin/nologin -M -g mysql

yuminstall ncurses-devel -y

1.4.2 解压编译MySQL

tarzxf mysql-5.5.32.tar.gz

cdmysql-5.5.32

cmake. -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data\

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock\

-DDEFAULT_CHARSET=gbk\

-DDEFAULT_COLLATION=gbk_chinese_ci\

-DENABLED_LOCAL_INFILE=ON\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\

-DWITHOUT_PARTITION_STORAGE_ENGINE=1

make

makeinstall

ln -s/application/mysql-5.5.32/ /application/mysql

如果上述操作未出现错误,则MySQL软件的安装就算成功了。

1.4.3 初始化配置MySQL

1.查看默认模板配置文件

[[email protected]]# ll support-files/my*.cnf

-rw-r--r--1 root root  4759 Apr 25 18:19support-files/my-huge.cnf

-rw-r--r--1 root root 19809 Apr 25 18:19 support-files/my-innodb-heavy-4G.cnf

-rw-r--r--1 root root  4733 Apr 25 18:19support-files/my-large.cnf

-rw-r--r--1 root root  4744 Apr 25 18:19support-files/my-medium.cnf

-rw-r--r--1 root root  2908 Apr 25 18:19support-files/my-small.cnf

2.选择配置文件

/bin/cpsupport-files/my-small.cnf /etc/my.cnf

测试环境选小的,生产环境可以根据硬件选择support-files/my-innodb-heavy-4G.cnf

3.配置环境变量

echo‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile

tail-1 /etc/profile

source/etc/profile

echo$PATH

4.初始化数据文件(容易出错的步骤)

#建立mysql数据文件目录

mkdir-p /application/mysql/data

#授权mysql用户访问mysql的安装目录

chown-R mysql.mysql /application/mysql/*

chmod-R 1777 /tmp

#初始化数据库文件(如果重新初始化数据库文件,必须先执行:rm -fr /application/mysql/data/*)

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql--datadir=/application/mysql/data --user=mysql

特别提示:

a.如果用mysql 5.0,5.1省略指定datadir会出错。

5.设置常规方式启动关闭脚本

cd/application/tools/mysql-5.5.32/

#拷贝mysql启动脚本到/etc/init.d/下

cpsupport-files/mysql.server /etc/init.d/mysqld

#授权700权限,即脚本可执行

chmod700 /etc/init.d/mysqld

/etc/init.d/mysqldstart

chkconfigmysqld on

chkconfig--list mysqld

6.登录mysql

7.简单优化mysql

a.删除test库:

mysql>show databases;

+--------------------+

|Database           |

+--------------------+

|information_schema |

|mysql              |

|performance_schema |

|test               |

+--------------------+

4 rowsin set (0.03 sec)

mysql>drop database test;

QueryOK, 0 rows affected (0.04 sec)

mysql>show databases;

+--------------------+

|Database           |

+--------------------+

|information_schema |

|mysql              |

|performance_schema |

+--------------------+

3 rowsin set (0.00 sec)

b.清除并修改管理员用户

mysql>select user,host from mysql.user;

+------+-----------+

| user| host      |

+------+-----------+

| root| 127.0.0.1 |

| root| ::1       |

|      | Mysql     |

| root| Mysql     |

|      | localhost |

| root| localhost |

+------+-----------+

6 rowsin set (0.00 sec)

mysql>delete from mysql.user;

QueryOK, 6 rows affected (0.07 sec)

mysql>select user,host from mysql.user;

Emptyset (0.00 sec)

mysql>grant all privileges on *.* to [email protected]‘localhost‘ identified by ‘1234‘ withgrant option;

QueryOK, 0 rows affected (0.00 sec)

mysql>flush privileges;

QueryOK, 0 rows affected (0.00 sec)

mysql>grant all privileges on *.* to [email protected]‘127.0.0.1‘ identified by ‘1234‘ withgrant option;

QueryOK, 0 rows affected (0.00 sec)

mysql>select user,host from mysql.user;

+--------+-----------+

|user   | host      |

+--------+-----------+

|system | 127.0.0.1 |

|system | localhost |

+--------+-----------+

2 rowsin set (0.00 sec)

操作过程:

[[email protected]]# cat /etc/redhat-release

CentOSrelease 6.4 (Final)

[[email protected]]# uname -r

2.6.32-358.el6.x86_64

[[email protected]]# uname -m

x86_64

[[email protected]]# tar zxf cmake-2.8.8.tar.gz

[[email protected]]# cd cmake-2.8.8

[[email protected]]# ./configure

CMakehas bootstrapped.  Now run gmake.

[[email protected]]# gmake

[[email protected]]# gmake install

[[email protected]]# groupadd mysql

[[email protected]]# useradd mysql -s /sbin/nologin -M -g mysql

[[email protected]]# tar zxf mysql-5.5.32.tar.gz

[[email protected]]# cd mysql-5.5.32

[[email protected]]# cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

cmake. -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data\

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock\

-DDEFAULT_CHARSET=gbk\

-DDEFAULT_COLLATION=gbk_chinese_ci\

-DENABLED_LOCAL_INFILE=ON\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\

-DWITHOUT_PARTITION_STORAGE_ENGINE=1

#Build files have been written to: /application/tools/mysql-5.5.32   如果显示这个表示cmake成功

[[email protected]]# make

[[email protected]]# make install

[[email protected]]# ln -s /application/mysql-5.5.32//application/mysql

[[email protected]]# ll support-files/my*.cnf

-rw-r--r--1 root root  4759 Apr 25 18:19support-files/my-huge.cnf

-rw-r--r--1 root root 19809 Apr 25 18:19 support-files/my-innodb-heavy-4G.cnf

-rw-r--r--1 root root  4733 Apr 25 18:19support-files/my-large.cnf

-rw-r--r--1 root root  4744 Apr 25 18:19support-files/my-medium.cnf

-rw-r--r--1 root root  2908 Apr 25 18:19support-files/my-small.cnf

[[email protected]]# cp support-files/my-small.cnf /etc/my.cnf

[[email protected]]# echo ‘export PATH=/application/mysql/bin:$PATH‘>>/etc/profile

[[email protected]]# tail -1 /etc/profile

exportPATH=/application/mysql/bin:$PATH

[[email protected]]# source /etc/profile

[[email protected]]# echo $PATH

/application/mysql/bin:/application/mysql/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[[email protected]]# mkdir -p /application/mysql/data

[[email protected]]# chown -R mysql.mysql /application/mysql/*

[[email protected]]# chmod -R 1777 /tmp

[[email protected]]# /application/mysql/scripts/mysql_install_db--basedir=/application/mysql --datadir=/application/mysql/data--user=mysql

[[email protected]]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected]]# chmod 700 /etc/init.d/mysqld

[[email protected]]# chkconfig mysqld on

[[email protected]]# chkconfig --list mysqld

mysqld          0:off   1:off  2:on    3:on    4:on   5:on    6:off

[email protected]]# mysql

Welcometo the MySQL monitor.  Commands end with; or \g.

YourMySQL connection id is 2

Serverversion: 5.5.32 Source distribution

Copyright(c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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

简单优化mysql

a.删除test库:

mysql>show databases;

+--------------------+

|Database           |

+--------------------+

|information_schema |

|mysql              |

|performance_schema |

|test               |

+--------------------+

4 rowsin set (0.03 sec)

mysql>drop database test;

QueryOK, 0 rows affected (0.04 sec)

mysql>show databases;

+--------------------+

|Database           |

+--------------------+

|information_schema |

|mysql              |

|performance_schema |

+--------------------+

3 rowsin set (0.00 sec)

b.清除并修改管理员用户

mysql>select user,host from mysql.user;

+------+-----------+

| user| host      |

+------+-----------+

| root| 127.0.0.1 |

| root| ::1       |

|      | Mysql     |

| root| Mysql     |

|      | localhost |

| root| localhost |

+------+-----------+

6 rowsin set (0.00 sec)

mysql>delete from mysql.user;

QueryOK, 6 rows affected (0.07 sec)

mysql>select user,host from mysql.user;

Emptyset (0.00 sec)

mysql>grant all privileges on *.* to [email protected]‘localhost‘ identified by ‘1234‘ withgrant option;

QueryOK, 0 rows affected (0.00 sec)

mysql>flush privileges;

QueryOK, 0 rows affected (0.00 sec)

mysql>grant all privileges on *.* to [email protected]‘127.0.0.1‘ identified by ‘1234‘ withgrant option;

QueryOK, 0 rows affected (0.00 sec)

mysql>select user,host from mysql.user;

+--------+-----------+

|user   | host      |

+--------+-----------+

|system | 127.0.0.1 |

|system | localhost |

+--------+-----------+

2 rowsin set (0.00

1、CMAKE安装Mysql时遇到的问题:

--Check size of wint_t - done

--Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMakeError at cmake/readlineNaNake:83 (MESSAGE):

Curses library not found.  Please install appropriate package,

remove CMakeCache.txt and rerun cmake.OnDebian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it isncurses-devel.

CallStack (most recent call first):

cmake/readlineNaNake:127 (FIND_CURSES)

cmake/readlineNaNake:217(MYSQL_USE_BUNDLED_LIBEDIT)

CMakeLists.txt:269 (MYSQL_CHECK_READLINE)

--Configuring incomplete, errors occurred!

解决方法:

rmCMakeCache.txt

yum install ncurses-devel -y

然后再cmake

CMAKE方式编译安装Mysql5.5

时间: 2024-10-14 06:56:57

CMAKE方式编译安装Mysql5.5的相关文章

linux下cmake方式编译安装MySQL数据库

前言:MySQL数据库自5.5版本以后,就开始使用CMake编译工具进行安装. 安装环境: [[email protected] ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.5 (Santiago)[[email protected] ~]# mysqladmin --versionmysqladmin  Ver 8.42 Distrib 5.6.14, for Linux on x86_64 1.安

cmake编译安装mysql5.5

CMAKE方式编译安装Mysql5.5 1.源码cmake方式编译安装MySQL5.5.32 安装前先安装: yum install ncurses-devel -y 1.1 下载Mysql和cmake安装包: wget http://wwwNaNake.org/files/v2.8/cmake-2.8.8.tar.gz 1.2 查看系统环境 cat /etc/redhat-release uname -r uname -m 1.3 安装cmake包 tar zxf cmake-2.8.8.ta

编译安装mysql-5.5.32

由于MySQL5.5.xx-5.6.xx产品系列特性,所以编译方式和早期产品安装方式不同 采用cmake方式编译安装MySQL-5.5.32 检查好所需的开发环境,小编在这里用的是centos6.5       执行以下命令即可:yum -y groupinstall "Development tools" "Compatibility libraries" 1.需要准备的安装包 wget /home/oldboy/tools http://mysql.ntu.ed

编译安装mysql-5.5.3

mysql从5.5版本以后基于cmake方式编译安装,而不是之前的make,因此要先安装好cmake,并把开发包组全部安装好: 1.先准备安装环境: #cmake下载地址:http://pkgs.fedoraproject.org/repo/pkgs/cmake/cmake-2.8.12.1.tar.gz/9d38cd4e2c94c3cea97d0e2924814acc/ [[email protected] ~]# yum  groupinstall -y  'Desktop Platform

CentOS6.7下使用cmake编译安装MySQL5.5.32笔记

一.安装cmake编译环境1.1 使用yum方式安装gcc [[email protected] ~]# yum install gcc 1.2 使用yum方式安装gcc-c++ [[email protected] ~]# yum install gcc-c++ 1.3 解压camke源文件 将cmake源文件放入/tmp/文件夹下 1 [[email protected] ~]# cd /tmp 2 [[email protected] ~]# tar -xf cmake-2.8.8.tar

开发人员学Linux(6):CentOS7编译安装MySQL5.17.8多实例及主从复制

1.前言上一篇讲述了如何在CentOS7下编译安装Nginx-1.12.0并如何配置反向代理,本篇将讲述如何编译安装MySQL5.7.18并配置多实例.2.准备2.1下载MySQL5.7.18源码注意最新版本的MySQL需要Boost才能编译安装,在MySQL提供的下载中有不带boost的源码,还有带boost的源码,如果下载不带boost的源码还需要再去下载boost源码,为省事起见,建议下载带boost的源码,下载地址:https://cdn.mysql.com//Downloads/MyS

编译安装MySQL-5.7.13

编译安装MySQL-5.7 cmake的重要特性之一是其独立于源码(out-of-source)的编译功能,即编译工作可以在另一个指定的目录中而非源码目录中进行,这可以保证源码目录不受任何一次编译的影响,因此在同一个源码树上可以进行多次不同的编译,如针对于不同平台编译. 编译安装MySQL-5.7 +++++++++++++++++++++++++OS:centos7 & 3.10.0-327.el7.x86_64MySQL:mysql-boost-5.7.13.tar.gz++++++++++

三、编译安装mysql-5.5.33

三.编译安装mysql-5.5.33 1.准备数据存放的文件系统: 新建一个逻辑卷(过程见链接),并将其挂载至/mydata/data目录, 做为mysql数据的存放目录. http://858004880.blog.51cto.com/7265424/1759317 2.新建用户以安全方式运行进程: 1.删除系统原来的mysql用户家目录 [[email protected] ~]# userdel -r mysql 2.创建mysql系统用户组 [[email protected] ~]# 

centos6.4下编译安装MySQL-5.5.33

若想在6.4版本下的centos编译安装MySQL必须使用新的编译器cmake. 1)安装cmake 直接yum安装 2)编译安装参数 使用cmake编译安装mysql-5.5.33,选项的方式有所改变: ./configure                cmake .            编译   ./configure –help         cmake . -LH or ccmake .   获取帮助 指定安装文件的安装路径时常用的选项:    -DCMAKE_INSTALL_P