源码编译mysql-5.6.15

.环境介绍

操作系统:CentOS6.4 


yum163源:http://mirrors.163.com/.help/CentOS6-Base-163.repo

 

.安装软件,源码安装方式

1.mysql 安装包mysql-5.6.15.tar.gz cmake-2.8.4.tar.gz

mysql下载地址:http://dev.mysql.com/downloads/mysql/

50pxake 安装包,mysql5.5以后需要cmake来编译

1. cmake安装包cmake-2.8.4.tar.gz

Cmake下载地址:http://download.chinaunix.net/download/0002000/1605.shtml

 

.检查是否已安装RPM包的mysql,如果已安装,卸载掉,以免端口被占用

rpm �Cqa |grep mysql

rpm �Ce �Cnodeps mysql  or yum �Cy remove mysql*

 

.安装软件

1.先安装cmake

tar �Caxf cmake-2.8.4.tar.gz

cd cmake-2.8.4

./configure

make

make install


2.创建mysql用户和用户组

groupadd mysql

useradd �Cr �Cg mysql mysql


3.编译mysql

tar �Caxf mysql-5.6.15.tar.gz

cd mysql-5.6.15

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data/  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci

以上参数等说明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql#mysql安装的主目录

-DMYSQL_DATADIR=/mydata/data/#mysql数据库文件存放目录

-DWITH_INNOBASE_STORAGE_ENGINE=1#安装innodb存储引擎

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock#系统socket文件(.sock)设置

-DMYSQL_USER=mysql  #默认为用户

-DDEFAULT_CHARSET=utf8 #使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci#校验字符


安装Mysql过程中出现的错误:

3.1没有安装gccgcc-c++

-- The C compiler identification is unknown

-- The CXX compiler identification is unknown

CMake Error: your C compiler:"CMAKE_C_COMPILER-NOTFOUND" was not found.   Please setCMAKE_C_COMPILER to a valid compiler path or name.

CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND"was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path orname.

解决方法:yum install �Cy  gcc  gcc-c++

3.2没有安装bison

Warning: Bison executable not found in PATH

解决方法:安装bison

yum install bison

rm CMakeCache.txt 

注意:重新编译要删除CMakeCache.txt文件,否则还会报错

3.3没有安装ncurses

removeCMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel.

解决方法:yum install �Cy ncurses-devel



4.初始化数据库

4.1给安装目录和数据存放目录mysql权限

chown -R mysql /mydata/data/

chown -R mysql/usr/local/mysql/


4.2初始化数据库时请注意看弹出的信息,以免有错误产生

scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql/ --datadir=/mydata/data/ --defaults-file=/etc/my.cnf


五.添加开机自启动

cp /usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld            #复制启动项文件

chkconfig --add mysqld

chkconfig  --level 123456 mysqld on


1.启动mysql时报错

service mysqld start

Starting MySQL.... ERROR! Theserver quit without updating PID file (/var/lib/mysql/nginx.server.com.pid).

解决方法:查看mysqllog(mysql log文件具体放在哪个地方可以看my.cnf文件,my.cnf一般在/etc/下or在安装MySQL的目录下)

/var/log/mysqld.log的错误信息[ERROR]Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn'texist

查看my.cnf文件时发现datadir的路径和我编译时不一样,改为datadir=/mydata/data/

wKiom1WDxM7wxqejAAEFy9c1-q8547.jpg


启动mysql成功

service mysqld start

Starting MySQL SUCCESS!

查看mysql端口

[[root@nginx log]# netstat-ntlp |grep mysqld

tcp        0     0 :::3306                    :::*                        LISTEN      35119/mysqld [root@nginx mysql]# bin/mysqladmin-u root passwd '123'

2.设置mysql密码

mysqladmin -u root password'123@qwe'

安装完成。。。。。。。。。。。。。。。。

wKioL1WDxxHCdjT8AAEz_Y4DoDA491.jpg





你可能感兴趣的:(mysql安装过程)