软件包全名:mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz (这个版本不用make,是已经mkae过的,类似window绿色软件)
可以在百度云上下载:https://pan.baidu.com/s/1raicyKG
[root@mysql ~]# ls
mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz redis-4.0.11.tar.gz ruby-devel-2.0.0.648-33.el7_4.x86_64.rpm
-1------创建mysql用户组和用户
[root@mysql ~]# groupadd mysql
[root@mysql ~]# useradd -g mysql -s /sbin/nologin mysql
-2------解压包放到/usr/local/下并改名为mysql5
[root@mysql ~]# tar -xf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
[root@mysql ~]# mv mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql5
-3------创建数据存放目录并修改相关目录所属
[root@mysql ~]# mkdir /data/mysql5
[root@mysql ~]# chown -R mysql:mysql /usr/local/mysql5
[root@mysql ~]# chown -R mysql:mysql /data/mysql5
-4------数据库初始化安装
[root@mysql ~]# cd /usr/local/mysql5/
[root@mysql mysql5]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@mysql mysql5]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5 --datadir=/data/mysql5
Installing MySQL system tables...2018-12-08 19:21:11 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-12-08 19:21:11 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
.......
New default config file was created as /usr/local/mysql5/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
-5------拷贝启动脚本并设置开机自启,并将mysql/bin下的命令做快捷链接
[root@mysql mysql5]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mysql mysql5]# chkconfig --add mysqld
[root@mysql mysql5]# source /etc/profile //最后面添加两行并保存
.....
export MYSQL_HOME="/usr/local/mysql"
export PATH="$PATH:$MYSQL_HOME/bin"
[root@mysql mysql5]# source /etc/profile //让配置立刻生效
-6------配置/etc/my.cnf(这个包没有自动在/etc目录下创建,所以手动创建或别的地方拷贝修改)
[root@mysql mysql5]# vim /etc/my.cnf //配置文件根据自己需求修改
// 这里主要修改下面两行
basedir = /usr/local/mysql5
datadir = /data/mysql5
[mysqld]
port = 1714
socket = /tmp/mysql.sock
basedir = /usr/local/mysql5
datadir = /data/mysql5
pid-file = /tmp/mysql.pid
user = mysql
bind-address = 0.0.0.0
#server-id = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
skip-name-resolve
#skip-networking
back_log = 300
max_connections = 7967
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 1024
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 128M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 256M
thread_cache_size = 64
-7------启动服务
[root@mysql mysql5]# service mysqld start
Starting MySQL. SUCCESS!
到这里就安装完成了,主要会碰到的问题是后面启动不了,那主要是配置文件问题。