1.准备工作
m4-1.4.18.tar.gz 下载地址:点击下载
bison-3.0.tar.gz 下载地址:点击下载
ncurses-6.0.tar.gz 下载地址:点击下载
cmake-3.7.2.tar.gz 下载地址:点击下载
mysql-5.6.33.tar.gz 下载地址:点击下载
2.依赖安装
可以在/home下创建一个mysql文件夹,然后把文件都下载到这个文件夹下
mkdir /home/mysql
chown -R server: /home/mysql
cd /home/mysql
C compiler:
apt-get install gcc build-essential
--------------------------------------------------------------
m4:
tar zxvf m4-1.4.18.tar.gz
cd m4-1.4.18
./configure
make && make install
man m4
--------------------------------------------------------------
bison:
tar zxvf bison-3.0.tar.gz
cd bison-3.0
./configure
make && make install
man bison
--------------------------------------------------------------
ncurses:
tar zxvf ncurses-6.0.tar.gz
cd ncurses-6.0
./configure
make && make install
man ncurses
--------------------------------------------------------------
cmake:
tar zxvf cmake-3.7.2.tar.gz
cd cmake-3.7.2
./bootstrap
make && make install
cmake --version
3.创建安装目录和数据目录
mkdir -p /usr/local/mysql
mkdir /data
4.创建用户和用户组
groupadd mysql
useradd mysql -g mysql -d /usr/local/mysql -M -s /sbin/nologin
#检查
grep mysql /etc/group
grep mysql /etc/passwd
5.解压目录
tar zxvf mysql-5.6.33.tar.gz
cd mysql-5.6.33/
ls -t
#所含文件
Docs scripts storage support-files unittest win mysql-test mysys_ssl plugin regex BUILD cmake dbug include libbinlogstandalone libmysql libservices config.h.cmake COPYING INSTALL VERSION
man sql strings testclients vio zlib mysys packaging rapid sql-common client cmd-line-utils extra libbinlogevents libevent libmysqld CMakeLists.txt configure.cmake Doxyfile-perfschema README
6.归属目录设置为mysql用户
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data
7.cmake编译工具编译mysql源代码
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_bin -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
8.编译和安装(建议磁盘大小30G以上)
make && make install
9.进入安装目录,并初始化数据库
cd /usr/local/mysql
./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data --user=mysql
10.配置mysql配置文件
cp -R my.cnf /etc/
11.修改my.cnf配置
vim /etc/my.cnf
#文件新增一下内容:
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /data/mysql.sock
# The MySQL server
[mysqld]
basedir = /usr/local/mysql
datadir = /data
port = 3306
socket = /data/mysql.sock
log-error = /data/mysql-error.log
pid-file = /data/mysql.pid
user = mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
group_concat_max_len = 102400
12.设置目录文件属于mysql用户
chown -R mysql.mysql /usr/local/mysql/
chown -R mysql.mysql /data
chown -R mysql.mysql /etc/my.cnf
13.启动mysql服务:
cd support-files/
./mysql.server start
cp -R mysql.server /etc/init.d/mysqld
chown -R mysql.mysql /etc/init.d/mysqld
service mysqld start
14.配置mysql环境变量
vim /etc/profile
#添加mysql配置
#mysql setting
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
source /etc/profile
15:此时安装完成,可以直接输入:mysql进行登录,然后切换到mysql,修改root的登录密码,并设置MySQL突破GROUP_CONCAT长度限制
grant all on *.* to dba@'%' Identified by 'soso036633';
use mysql
UPDATE user SET Password = PASSWORD('soso036633') WHERE user = 'root';
SET GLOBAL group_concat_max_len = 102400;
16.重启mysql服务,此时登录需要密码,输入密码登录即可。
mysql -u root -p