CentOS6.5编译安装MySQL5.5

安装依赖包:
yum -y install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool*
安装cmake:
[root@localhost usr]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz
[root@localhost usr]# tar xzvf cmake-2.8.12.tar.gz 
[root@localhost usr]# cd cmake-2.8.12
[root@localhost cmake-2.8.12]# ./bootstrap 
[root@localhost cmake-2.8.12]# gmake 
[root@localhost cmake-2.8.12]# gmake install
添加MySQL用户和用户组:
[root@localhost cmake-2.8.12]# cd ~
[root@localhost ~]# groupadd mysql 
[root@localhost ~]# useradd -g mysql mysql
创建MYSQL安装目录并授权:
[root@localhost ~]# mkdir /usr/local/mysql
[root@localhost ~]# mkdir /usr/local/mysql/data
[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
下载MySQL源代码:
[root@localhost ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.45.tar.gz
[root@localhost ~]# tar xzvf mysql-5.5.45.tar.gz 
[root@localhost ~]# cd mysql-5.5.45
配置MySQL编译参数:
[root@localhost ~]#
					cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
					-DMYSQL_DATADIR=/usr/local/mysql/data \
					-DWITH_INNOBASE_STORAGE_ENGINE=1 \
					-DWITH_PARTITION_STORAGE_ENGINE=1 \
					-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
					-DWITH_MYISAM_STORAGE_ENGINE=1 \
					-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
					-DMYSQL_TCP_PORT=3306 \
					-DENABLED_LOCAL_INFILE=1 \
					-DWITH_EXTRA_CHARSETS=all \
					-DDEFAULT_CHARSET=utf8 \
					-DDEFAULT_COLLATION=utf8_general_ci \
					-DWITH_SSL=yes
进行编译安装:
[root@localhost ~]# make && make install
配置my.cnf:
[root@localhost support-files]# cd /usr/local/mysql/support-files
[root@localhost support-files]# cp my-medium.cnf /etc/my.cnf
[root@localhost support-files]# vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/tmp/mysql.sock
character-set-server=utf8
max_connections=300
default-storage-engine=InnoDB
collation-server=utf8_bin
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
port=3306
default-character-set=utf8
[mysql]
no-auto-rehash
default-character-set=utf8
[safe_mysqld] 
err-log=/var/log/mysqld.log 
pid-file=/var/lib/mysql/mysql.pid
初始化数据库:
[root@localhost support-files]# 
								/usr/local/mysql/scripts/mysql_install_db \
								--defaults-file=/etc/my.cnf \
								--basedir=/usr/local/mysql \
								--datadir=/usr/local/mysql/data \
								--user=mysql
设置开机自启动 
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# chmod +x /etc/init.d/mysqld
[root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# chkconfig --level 345 mysqld on
启动服务:
[root@localhost support-files]# service mysqld start
设置密码:
[root@localhost support-files]# /usr/local/mysql/bin/mysqladmin password [new-password]
设置一个软链接:
[root@localhost support-files]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
登录MySQL:
[root@localhost support-files]# mysql -uroot -p


你可能感兴趣的:(CentOS6.5编译安装MySQL5.5)