mysql5.6.8源码安装

内核:

[root@opop ~]# cat /etc/centos-release
CentOS release 6.8 (Final)
[root@opop ~]# uname -a
Linux opop 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

 


mysql5.6.8的源码包下载地址:https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.38.tar.gz

 

开始安装:
[root@opop ~]# for i in `rpm -qa | grep mysql`;do yum remove $i;done      //先删除自带的mysql
[root@opop ~]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl bison git

 

创建mysql用户组:
[root@opop ~]# groupadd mysql
[root@opop ~]# useradd -r -g mysql mysql

 

创建mysql安装目录和数据库文件存放目录:
[root@opop ~]# mkdir -p /usr/local/mysql
[root@opop ~]# mkdir -p /usr/local/mysql/data

 

修改目录属主和属组:
[root@opop ~]# chown -R mysql:mysql /usr/local/mysql/data
[root@opop ~]# chown -R mysql:mysql /usr/local/mysql


解包:
[root@opop ~]# tar -zxvf mysql-5.6.38.tar.gz
[root@opop ~]# cd mysql-5.6.38

编译:
[root@opop mysql-5.6.38 ]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_USER=mysql \
-DENABLE_DOWNLOADS=1

 

[root@opop mysql-5.6.38 ]# make && make install
//注:编译时间较长,需要耐心等待

 

//查看下结果:
//[root@opop mysql-5.6.38 ]# ll /usr/local/mysql/


清除临时文件:
[root@opop mysql-5.6.38 ]# make clean


初始化mysql:
[root@opop ~]# cd /usr/local/mysql/
[root@opop mysql]# scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
[root@opop mysql ]# chown -R mysql:mysql /usr/local/mysql
[root@opop mysql ]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@opop mysql ]# /etc/init.d/mysql start
[root@opop mysql ]# ps -aux |grep mysql

配置环境变量:
[root@opop mysql]# vim /etc/profile
在后面加上
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH

 

重新加载profile(是立即生效)
[root@opop mysql]# source /etc/profile

 

重启mysql服务:
[root@opop mysql]# service mysql restart


首次登陆:
[root@opop mysql]# mysql -u root mysql

 

授权:
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
//为root添加远程连接的能力,据需谨慎操作。

 

设置数据库密码:
mysql> update user set password = password('111111') where User='root';               //更新root密码为6个1

 

刷新:
mysql> flush privileges;

 

退出:
mysql> exit

 

更改完密码以后再次登录:
[root@opop mysql]# mysql -u root -p
Enter password:                             //这里输入6个1即可进来

 

设置开机自动启动服务:
[root@opop mysql]# chkconfig mysql on

 

posted @ 2018-01-10 13:32  Linux大魔王  阅读(156)  评论(0编辑  收藏  举报