转载地址:http://www.apelearn.com/bbs/thread-7743-1-1.html
1.首先下载源码包,解压到目录(需安装编译使用的环境)
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz
2.切换到mysql所在目录执行cmake命令
3.由于系统没有cmake命令,于是yum install cmake -y 进行安装
4.前面步骤细节就省略了,直接到cmake这里:
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql_data -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
报错如下:
-- 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:250 (MYSQL_CHECK_READLINE)
解决方法:
[root@localhost mysql-5.6.1]# rm CMakeCache.txt
[root@localhost mysql-5.6.1]# yum install ncurses-devel
[root@localhost mysql-5.5.11]# yum install bison
接着继续执行编译
#cmake......
#make && make install
2.编译完成,安装好之后
2.1 新建系统用户mysql ,并禁止登陆
#useradd -s /sbin/nologin mysql
2.2 建立数据库存放目录
#mkdir -p /data/mysql_data
#chown -R mysql:mysql /data/mysql_data
2.3进行数据库初始化:
#cd /usr/local/mysql
#./scripts/mysql_install_db --user=mysql --datadir=/data/mysql_data
#cp support-files/my-large.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysqld
#chmod 755 /etc/init.d/mysqld
#vim /etc/init.d/mysqld //添加datadir=路径
#service mysqld start -------------------------------服务启动报错
报错信息如下:
[root@centos6 mysql_data]# service mysqld start
Starting MySQL...The server quit without updating PID file [失败]/mysql_data/centos6.6.pid).
解决方法:
根据报错信息,怀疑可能文件丢失造成的原因,对比我另外一个测试机已经搭建好的环境,检查同样的数据库目录下,发现本机确实少了一个centos6.6.pid文件
解决方法:
#cd /data/mysql_data //数据库文件存放目录
#vi centos6.6.pid //编辑此文件,添加一个pid号码
1583
保存退出。 //1583是我在系统中随意添加的号,只要保证系统进程里没有的ID都可以
#service mysqld start 正常启动 ----------------------------成功解决