Linux下安装mysql5.6

环境:

Rhel6.5+ cmake-2.8.10.2 + mysql-5.6.16

 

Cmake下载地址:http://www.cmake.org/files

Mysql下载地址:http://pan.baidu.com/s/1bno9Cz9 密码:kayn

 

准备工作:

检测gcc gcc-c++  ncurses-devel perl工具与库是否已经安装。

 

检测命令:rpm �Cqa | grep [ gcc gcc-c++ncurses-develperl ]

若没有安装,可使用命令:yum �Cy install完成安装。

 

1、编译安装cmake

tarzxf cmake-2.8.10.2.tar.gz

cdcmake-2.8.10.2

./bootstrap&& make && make install

 

2、创建 mysql 用户和组:

groupaddmysql

useradd-g -r mysql mysql

 

3、解压并编译安装mysql

tarzxf mysql-5.6.16.tar.gz

cdmysql-5.6.16

cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

          -DDEFAULT_CHARSET=utf8 \

          -DDEFAULT_COLLATION=utf8_general_ci \

          -DMYSQL_TCP_PORT=3306 \

          -DMYSQL_USER=mysql \

          -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \

          -DMYSQL_DATA=/usr/local/mysql/data \

          -DENABLED_LOCAL_INFILE=1

make&& make install

 

cmake参数中文手册: http://linuxrookie.blog.51cto.com/8832240/1658368 

 

●注:若编译失败需清空编译缓存,如何重新编译安装。具体命令如下:

make clean

rm -f CmakeCache.txt

make && make install

 

4、修改用户属组(主):

chown-R mysql:mysql /usr/local/mysql

 

5、设置mysql配置文件:

cp/usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

提示是否覆盖原有文件,输入y

 

6、设置mysql启动配置文件:

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

 

7、初始化mysql

/usr/local/mysql/sctipts/mysql_install_db--basedir=/usr/local/mysql --database=/usr/local/mysql/data --user=mysql

 

8、将mysql加入启动项:

chkconfig--add mysqld

chkconfig--level 345 mysqld on

 

9、启动mysql

servicemysqld start

 

10、设置mysql环境变量:

vim/etc/profile

添加下面两行

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

exprotPATH

 

 

11、可能出现的报错:

11.1

ERROR2002 (HY000): Can't connect to local MySQL server through socket'/var/mysql/mysql.sock' (2)

解决办法:

ln-s /tmp/mysqld.sock /var/mysql/mysql.sock (事先要在/var下创建好mysql目录,mysqld.sock的位置为编译时参数内指定的位置,不一定在/tmp下)

 

11.2

FATALERROR: Could not find ./bin/my_print_defaults

Ifyou compiled from source, you need to run 'make install' to copy the softwareinto the correct location ready for operation.

Ifyou are using a binary release, you must either be at the top level of theextracted archive, or pass the --basedir option pointing to that location.

可能原因:

在初始化的时候未加上参数--basedir --datadir

解决办法:

/usr/lcoal/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

重新初始化mysql一定加上 --basedir --datadir 参数。(具体路径根据个人编译设定为准)


你可能感兴趣的:(linux,mysql,数据库,RHEL,5.6)