MySQL-5.5.11 源码安装
操作系统:centos 6.3 x64
1、创建mysql安装目录
# mkdir -p /usr/local/mysql/
2、创建用户和用户组与赋予数据存放目录权限
# groupadd mysql
# useradd -g mysql mysql
# chown mysql.mysql -R /service/mysql/
3、安装cmake(mysql5.5以后是通过cmake来编译的)
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make && make install
增加用户组和用户
groupadd mysql
useradd -r -g mysql mysql
将压缩包.tar.gz解压缩到所需的目录
进入解压缩的目录
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
安装遇到错误:
– MySQL 5.5.11
– Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu , package name is libncurses5-dev ,
on RedHat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:256 (MYSQL_CHECK_READLINE)
– Configuring incomplete, errors occurred!
下载工具libncurses5-dev,如果在RedHat 下是ncurses-devel。
下载之后先移除目录中的CMakeCache.txt
然后输入
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
遇到警告:
Warning: Bison executable not found in PATHWarning: no usable bison found, /usr/src/mysql-5.5.11/sql/sql_yacc.yy will not be rebuilt.
下载工具:bison
下载之后先移除目录中的CMakeCache.txt
然后输入
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
没有警告和错误发生,然后输入
make
make install
编译结束
cd /usr/local/mysql
sudo chown -R mysql . //修改mysql目录的所有者
sudo chgrp -R mysql . //修改mysql目录的所有群组
scripts/mysql_install_db --user=mysql
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start
/usr/local/mysql/bin/mysql -u root -p
mysql>use mysql ;
mysql>update user set password=PASSWORD("xxxxxx") where user='root';
mysql>FLUSH PRIVILEGES;
转载于:https://blog.51cto.com/zhyuxuan/1073159