CentOS 6.5 源码安装MySQL-5.6.35

1.检查是否安装有mysql(用yum remove卸载即可)

[root@localhost ~]# rpm -qa|grep -i mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-libs-5.1.71-1.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64

2.安装编译代码需要的包

[root@localhost ~]# yum -y install make gcc gcc-c++ cmake bison-devel ncurses-devel

3.wget下载mysql-5.6.35软件包并解压

[root@localhost ~]# wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.35.tar.gz
[root@localhost ~]# tar zxvf mysql-5.6.35.tar.gz

4.创建安装目录

[root@localhost ~]# mkdir -p /usr/local/mysql/data

5.编译安装

[root@localhost mysql-5.6.35]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
[root@localhost mysql-5.6.35]# make && make install
[root@localhost mysql-5.6.35]# make clean

6.查看是否有mysql用户及用户组

[root@localhost mysql-5.6.35]# cat /etc/passwd
[root@localhost mysql-5.6.35]# cat /etc/group
(如果没有就添加mysql用户和组)
[root@localhost mysql-5.6.35]# groupadd mysql
[root@localhost mysql-5.6.35]# useradd -g mysql mysql
(修改/usr/local/mysql权限)
[root@localhost mysql-5.6.35]# chown -R mysql:mysql /usr/local/mysql

7.初始化配置

[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# chkconfig mysql on

8.启动MySQL

[root@localhost mysql]# service mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
 SUCCESS!

10.配置用户

[root@localhost mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile[root@localhost mysql]# source /etc/profile
[root@localhost mysql]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin

修改root密码

[root@localhost mysql]# mysql -uroot
mysql> set password = password('ibelieveicanfly');
Query OK, 0 rows affected (0.00 sec)

你可能感兴趣的:(CentOS 6.5 源码安装MySQL-5.6.35)