安装rz工具和wget工具:分别如下: sudo yum install lrzsz;yum install wget 安装cmake编译工具:rz -y 选择下载的cmake工具上传到服务器中 安装c、c++:yum -y install gcc-c++
环境参数:Linux:Centos6.5,cmake:2.8.8,mysql:5.6.12
1.下载cmake-2.8.8.tar
2.安装cmake
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
gmake && gmake install
3.下载mysql-5.6.35.tar
4.添加mysql用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
5.安装ncurses-devel
yum install ncurses-devel -y
6.解压mysql
tar xf mysql-5.6.12.tar.gz
cd mysql-5.6.12
7.编译mysql cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.12 \ -DMYSQL_DATADIR=/application/mysql-5.6.12/data \ -DMYSQL_UNIX_ADDR=/application/mysql-5.6.12/mysql.sock \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0
注:如果make到63%左右出现错误: make[2]: * [storage/perfschema/unittest/pfs_connect_attr-t] Error 1 make[1]: * [storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/all] Error 2 则:cmake去掉-DWITH_PARTITION_STORAGE_ENGINE=1参数重新编译 8.mysql安装 make && make install
9.做软连接 ln -s /application/mysql-5.6.12/ /application/mysql
10.mysql目录授权 chown -R mysql:mysql /application/mysql-5.6.12/
11.相关文件 cd /application/mysql/support-files cp my-default.cnf /etc/my.cnf cp mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld
12.mysql初始化 cd /application/mysql/scripts/ ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
报错:-bash: ./mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory
安装perl-devel,yum install perl-devel
13.启动mysql /etc/init.d/mysqld start
14.配置环境变量 echo 'export PATH=/application/mysql/bin:$PATH'>>/etc/profile source /etc/profile
15.登陆mysql,删除无用配置,只保留如下,并删除test数据库
mysql> select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | localhost | +------+-----------+ mysql> drop database test;
16.配置登陆密码 /application/mysql//bin/mysqladmin -u root password 'cancer'
17.设置mysql开机启动 chkconfig mysqld on chkconfig --list mysqld