mysql安装 

yum -y install gcc gcc-c++
yum -y install pcre-devel zlib-devel
yum install pcre pcre-devel
yum install gcc gcc-c++ cmake ncurses-devel bison
yum install openssl openssl-devel –y
yum install pcre pcre-devel –y


cmake编译mysql

1.3 安装相关包

1.3.1 cmake软件

cd /home/oldboy/tools/

tar xf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

#CMake has bootstrapped.  Now run gmake.

gmake

gmake install

cd ../

1.3.2 依赖包

yum install ncurses-devel –y


1.4.1 创建用户和组

groupadd mysql

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


1.4.2 解压编译MySQL

tar zxf mysql-5.5.32.tar.gz

cd mysql-5.5.32

1.4.2 解压编译MySQL

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


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

在mysql-5.5.32解压包中 复制配置文件到etc下

Cp  support-files/my-small.cnf   /etc/my.cnf

配置环境变量

mysql-cmake编译_mysql

或者

vim /etc/profile

最底下修改:

PATH="/application/mysql/bin/:$PATH"

tail -1  /etc/profile

source /etc/profile

 mysql-cmake编译_mysql_02

mysql-cmake编译_mysql_03

给data目录授权

chown -R  mysql.mysql  /application/mysql/data/

数据库初始化

cd /application/mysql/scripts/

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

mysql-cmake编译_数据库_04

#没有错误的话进行下一步

进入mysql解压目录

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

 vim /etc/init.d/mysqld

basedir=/application/mysql

datadir=/application/mysql/data


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

或者

\cp -f support-files/my-small.cnf  /etc/my.cnf


/etc/init.d/mysqld start

/etc/init.d/mysqld stop




如果启动报错 启动不了  就重新初始化

pkill mysqld

lsof -i :3306

rm -rf /application/mysql/data/*


修改数据库密码

/application/mysql/bin/mysqladmin  -u root password '123456'


进入mysql库

/application/mysql/bin/mysql

或者添加到mysql命令

mysql-cmake编译_初始化_05

优化:

delete from mysql.user where host="::1";

delete from mysql.user where host="www";

delete from mysql.user where user="";

mysql-cmake编译_数据库_06

mysql-cmake编译_数据库_07