CentOS 6.3 安裝MySQL-5.7.10
MySQL的安裝分為三種:
1、RPM包安裝;
2、二進位制包安裝;
3、原始碼安裝。
第一種方式比較簡單,直接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
複製my.cnf檔案
[mysql@guoqing mysql]$ su
Password:
[root@guoqing mysql]# cp support-files/my-default.cnf /etc/
[root@guoqing mysql]# chown mysql.mysql /etc/my.cnf
複製MySQL服務檔案
[root@guoqing mysql]# cp support-files/mysql.server /etc/init.d/mysql
在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"
fi
# datadir_set is used to determine if datadir was set (and so should be
# *not* set inside of the --basedir= handler.)
datadir_set=
#
# Use LSB init script functions for printing messages, if possible
#
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
"/etc/rc.d/init.d/mysql" 393L, 10981C written
[root@guoqing mysql]# exit
exit
修改my.cnf檔案,主要新增basedir、datadir
[mysql@guoqing mysql]$ vi /etc/my.cnf
[mysqld]
basedir=/home/mysql/mysql
datadir=/home/mysql/mysql/data
socket=/home/mysql/mysql/mysql.sock
user=mysql
# 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
初始化MySQL
MySQL 5.7.6之後版本為 ./bin/mysqld --initialize --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data/
[mysql@guoqing mysql]$ ./bin/mysqld --initialize --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data/
2016-01-12T16:16:14.765586Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-01-12T16:16:14.765847Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2016-01-12T16:16:14.766086Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-12T16:16:15.038567Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-01-12T16:16:15.095995Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-12T16:16:15.166081Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cdd34871-b947-11e5-8a45-0800272a2c8e.
2016-01-12T16:16:15.168260Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-01-12T16:16:15.168776Z 1 [Note] A temporary password is generated for root@localhost: qnW8usF=o;=e(root使用者密碼)
MySQL 5.7.6之前的版本為bin/mysql_install_db --user=mysql
建立 SSL/RSA 檔案
參見:http://dev.mysql.com/doc/refman/5.7/en/mysql-ssl-rsa-setup.html
[mysql@guoqing mysql]$ bin/mysql_ssl_rsa_setup --datadir=/home/mysql/mysql/data/
Generating a 2048 bit RSA private key
...............................+++
.............................................................................................................................................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
............................................+++
...................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
...........................................................................................................................................+++
......+++
writing new private key to 'client-key.pem'
-----
新增環境變數:/home/mysql/mysql/bin
[mysql@guoqing ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/home/mysql/mysql/bin
export PATH
~
".bash_profile" 12L, 198C written
使變數生效
[mysql@guoqing ~]$ . .bash_profile
啟動MySQL服務
[mysql@new ~]$ service mysql start
Starting MySQL. [ OK ]
登入
用到上面日誌中的密碼,注意qnW8usF=o;=e全是密碼內容
[mysql@guoqing ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.10
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
修改密碼
mysql> set password=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
至此,MySQL5.7.10安裝完成,整體與5.6安裝差別不大,便要注意root密碼的長度,初始化方式等。
1、RPM包安裝;
2、二進位制包安裝;
3、原始碼安裝。
第一種方式比較簡單,直接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
複製my.cnf檔案
[mysql@guoqing mysql]$ su
Password:
[root@guoqing mysql]# cp support-files/my-default.cnf /etc/
[root@guoqing mysql]# chown mysql.mysql /etc/my.cnf
複製MySQL服務檔案
[root@guoqing mysql]# cp support-files/mysql.server /etc/init.d/mysql
在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"
fi
# datadir_set is used to determine if datadir was set (and so should be
# *not* set inside of the --basedir= handler.)
datadir_set=
#
# Use LSB init script functions for printing messages, if possible
#
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
"/etc/rc.d/init.d/mysql" 393L, 10981C written
[root@guoqing mysql]# exit
exit
修改my.cnf檔案,主要新增basedir、datadir
[mysql@guoqing mysql]$ vi /etc/my.cnf
[mysqld]
basedir=/home/mysql/mysql
datadir=/home/mysql/mysql/data
socket=/home/mysql/mysql/mysql.sock
user=mysql
# 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
初始化MySQL
MySQL 5.7.6之後版本為 ./bin/mysqld --initialize --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data/
[mysql@guoqing mysql]$ ./bin/mysqld --initialize --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data/
2016-01-12T16:16:14.765586Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-01-12T16:16:14.765847Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2016-01-12T16:16:14.766086Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-12T16:16:15.038567Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-01-12T16:16:15.095995Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-12T16:16:15.166081Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cdd34871-b947-11e5-8a45-0800272a2c8e.
2016-01-12T16:16:15.168260Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-01-12T16:16:15.168776Z 1 [Note] A temporary password is generated for root@localhost: qnW8usF=o;=e(root使用者密碼)
MySQL 5.7.6之前的版本為bin/mysql_install_db --user=mysql
建立 SSL/RSA 檔案
參見:http://dev.mysql.com/doc/refman/5.7/en/mysql-ssl-rsa-setup.html
[mysql@guoqing mysql]$ bin/mysql_ssl_rsa_setup --datadir=/home/mysql/mysql/data/
Generating a 2048 bit RSA private key
...............................+++
.............................................................................................................................................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
............................................+++
...................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
...........................................................................................................................................+++
......+++
writing new private key to 'client-key.pem'
-----
新增環境變數:/home/mysql/mysql/bin
[mysql@guoqing ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/home/mysql/mysql/bin
export PATH
~
".bash_profile" 12L, 198C written
使變數生效
[mysql@guoqing ~]$ . .bash_profile
啟動MySQL服務
[mysql@new ~]$ service mysql start
Starting MySQL. [ OK ]
登入
用到上面日誌中的密碼,注意qnW8usF=o;=e全是密碼內容
[mysql@guoqing ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.10
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
修改密碼
mysql> set password=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
至此,MySQL5.7.10安裝完成,整體與5.6安裝差別不大,便要注意root密碼的長度,初始化方式等。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2018555/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Centos-6.3安裝NginxCentOSNginx
- Mono on CentOS 6.3 安裝筆記MonoCentOS筆記
- CentOS7 安裝mysql-5.7.10(glibc版)CentOSMySql
- CentOS 6.3下快速安裝MongoDB 3.2.1CentOSMongoDB
- CentOS 6.3安裝(詳細圖解教程)CentOS圖解
- 在CentOS 6.3中安裝與配置cmakeCentOS
- CentOS 6.3下Puppet安裝配置筆記CentOS筆記
- CentOS6.3下安裝MySQL GA 5.6.10CentOSMySql
- Centos6.3編譯安裝Nginx+php+MysqlCentOS編譯NginxPHPMySql
- Centos6.3下jdk+tomcat安裝部署CentOSJDKTomcat
- Centos64位6.3 下安裝 Mysql5.6CentOSMySql
- CentOS6.3安裝lnmp(php5.4,mysql5.6)CentOSLNMPPHPMySql
- CentOS 6.3下rsync伺服器的安裝與配置CentOS伺服器
- CentOS 6.3下Samba伺服器的安裝與配置CentOSSamba伺服器
- 【PHP升級】CentOS6.3編譯安裝 PHP5.4.38PHPCentOS編譯
- Centos下安裝破解confluence6.3的操作記錄CentOS
- Cent os 6.3上安裝rlwrap
- RHEL 6.3 詳細安裝教程
- CentOS 6.5安裝Oracle 11.2.0.4------CentOS 6.5安裝CentOSOracle
- CentOS安裝jdkCentOSJDK
- CentOS安裝gitCentOSGit
- Centos 安裝RedisCentOSRedis
- CentOS 安裝 mavenCentOSMaven
- CentOS Docker 安裝CentOSDocker
- centOS安裝rabbitMQCentOSMQ
- CentOS 安裝 dockerCentOSDocker
- CentOS安裝pipCentOS
- Centos安裝opensslCentOS
- CentOS 安裝ScrapyCentOS
- CentOS 安裝ErlangCentOS
- CentOS安裝GraphicsMagickCentOS
- CentOS 安裝 JDKCentOSJDK
- Centos安裝rubyCentOS
- CentOS安裝DockerCentOSDocker
- CentOS 安裝PHPCentOSPHP
- CentOS安裝MySQLCentOSMySql
- centos 安裝swftoolsCentOS
- mongo centos 安裝GoCentOS