第一种方式比较简单,直接RPM包安装就OK了,或者通过yum源来安装,但无法自定义安装目录。 而第三种方式比较复杂。 一般项目中使用比较多的是通过二进制包来安装,这种安装方式可以根据企业的不同需求进行相关的自定义配置,比如安装在哪个目录,如何配置等。 MySQL5.7与5.6安装有所改变。 CentOS版本 [mysql@new ~]$ cat /etc/redhat-release CentOS release 6.3 (Final) [mysql@new ~]$ 把安装文件上传至服务器 [mysql@new ~]$ ls total 535920 -rw-rw-rw-. 1 mysql mysql 548774698 Jan 12 16:53 mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz 解压安装文件 [mysql@new ~]$ tar -xvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz 重命名目录 [mysql@guoqing ~]$ mv mysql-5.7.10-linux-glibc2.5-x86_64 mysql [mysql@guoqing ~]$ ls mysql mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz [mysql@guoqing ~]$ cd mysql [mysql@guoqing mysql]$ ls bin COPYING docs include INSTALL-BINARY lib man README share support-files
新建存放数据的目录data [mysql@guoqing mysql]$ mkdir data [mysql@guoqing mysql]$ ll total 164 drwxr-xr-x. 2 mysql mysql 4096 Nov 30 03:54 bin -rw-r--r--. 1 mysql mysql 17987 Nov 30 03:16 COPYING drwxrwxr-x. 2 mysql mysql 4096 Jan 12 23:38 data drwxr-xr-x. 2 mysql mysql 4096 Nov 30 03:54 docs drwxr-xr-x. 3 mysql mysql 4096 Nov 30 03:54 include -rw-r--r--. 1 mysql mysql 108090 Nov 30 03:26 INSTALL-BINARY drwxr-xr-x. 5 mysql mysql 4096 Nov 30 03:54 lib drwxr-xr-x. 4 mysql mysql 4096 Nov 30 03:54 man -rw-r--r--. 1 mysql mysql 2478 Nov 30 03:16 README drwxr-xr-x. 28 mysql mysql 4096 Nov 30 03:54 share drwxr-xr-x. 2 mysql mysql 4096 Nov 30 03:54 support-files
在MySQL服务文件中把/usr/local/指替换成自己安装MySQL目录 这里是替换成的home/mysql [root@guoqing mysql]# vi /etc/init.d/mysql # 0 means don't wait at all # Negative numbers mean to wait indefinitely service_startup_timeout=900 # Lock directory for RedHat / SuSE. lockdir='/var/lock/subsys' lock_file_path="$lockdir/mysql" # The following variables are only set for letting mysql.server find things. # Set some defaults mysqld_pid_file_path= if test -z "$basedir" then basedir=/home/mysql/mysql bindir=/home/mysql/mysql/bin if test -z "$datadir" then datadir=/home/mysql/mysql/data fi sbindir=/home/mysql/mysql/bin libexecdir=/home/mysql/mysql/bin else bindir="$basedir/bin" if test -z "$datadir" then datadir="$basedir/data" fi sbindir="$basedir/sbin" libexecdir="$basedir/libexec"
# Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/home/mysql/mysql/data/mysqld.log pid-file=/home/mysql/mysql/data/mysqld/mysqld.pid "/etc/my.cnf" 11L, 316C written