首页 > 代码库 > 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、安装rz、sz
yum install lrzsz
4、修改字符集
vi /etc/sysconfig/i18n
本文出自 “运维小当家” 博客,请务必保留此出处http://solin.blog.51cto.com/11319413/1888798
MySQL-5.5 cmake编译安装