首页 > 代码库 > MySQL-5.5 cmake编译安装

MySQL-5.5 cmake编译安装

MySQL-5.5编译安装

一、安装前准备

1.1下载MySQL安装包

wget http://wwwNaNake.org/files/v2.8/cmake-2.8.10.2.tar.gz
wget ftp://ftp.ntu.edu.tw/tmp/MySQL/Downloads/MySQL-5.5/mysql-5.5.32.tar.gz

技术分享

1.2 安装相关的包

1.2.1 cmake软件

cd /root/tools

技术分享

tar -zxvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
执行时出错,缺少依赖
---------------------------------------------
CMake 2.8.10.2, Copyright 2000-2012 Kitware, Inc.
C compiler on this system is: cc 
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /root/tools/cmake-2.8.10.2/BootstrapNaNk/cmake_bootstrap.log

解决办法:安装g++和ncurses-devel
yum -y install gcc-c++ ncurses-devel cmake;

重新安装执行
./bootstrap

gmake && gmake install

二、开始安装mysql

1.1 创建用户和组

groupadd mysql

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

技术分享

1.2 解压编译MySQL

cd /root/tools

tar zxf mysql-5.5.32.tar.gz

cd 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=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \

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

-DWITH_FAST_MUTEXES=1 \

-DWITH_ZLIB=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_DEBUG=0

技术分享

make && make install

技术分享

1.3添加链接

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

技术分享

三、初始化配置pysql

1.1查看默认模板配置文件

ll support-files/my*cnf

技术分享

2.1选择配置文件

/bin/cp support-files/my-small.cnf /etc/my.cnf

测试环境选择小的,生成环境可以根据硬件选择,例如:my-innodb-h-heavy-4G.cnf

技术分享

3.1配置环境变量

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

tail -l /etc/profile

技术分享

source /etc/profile

echo $PATH

技术分享

4.1初始化数据文件

mkdir -p /application/mysql/data #建立mysql数据文件目录(已有不用创建)

chown -R mysql.mysql /application/mysql/data/ #授权mysql用户访问mysql的安装目录

chown -R 1777 /tmp/ #调整/tmp权限,否则初始化会错误

技术分享

cd /application/mysql/scripts/

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

技术分享

/bin/cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

/etc/init.d/mysqld start

技术分享

四、数据库简单优化(删除多余的用户)

1.1进入数据库

技术分享

1.2删除多余用户

mysql> select user,host from mysql.user;

mysql> delete from mysel.user where user=’ ’;

mysql> delete from mysql.user where host=‘::1‘;

mysql> delete from mysql.user wherehost=‘CentOS‘;

技术分享

技术分享

1.3查看databases

mysql> show databases;

mysql> drop database test;

技术分享

2.1增加密码

/application/mysql//bin/mysqladmin -u root password‘centos‘

技术分享

3.1设置开机启动

chkconfig mysqld on

chkconfig --list mysqld

技术分享

4.1删除全部,添加额外管理员

>delete from mysql.user;

>grant all privileges on *.*to system@’locahost’identified by ‘centos’ with grant option;

 

5.1mysql登陆

mysql -uroot -p

技术分享

五、可能用到的命令

1、查看系统版本

cat /etc/redhat-release

uname –m

技术分享

2、修改yum

选择添加的源

技术分享

wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

技术分享

yum makecache

 

 

3、安装rzsz

yum install lrzsz

技术分享

 

4、修改字符集

vi /etc/sysconfig/i18n

技术分享


本文出自 “运维小当家” 博客,请务必保留此出处http://solin.blog.51cto.com/11319413/1888798

MySQL-5.5 cmake编译安装