RHEL 7.2 安裝 MySQL 5.7.11 二進位版

來源:互聯網
上載者:User

標籤:mysql5.7 安裝

作業系統:rhel7.2 

MySQL版本:5.7.11

1、MySQL下載

  http://dev.mysql.com/downloads/

2、上傳MySQL軟體到作業系統

[[email protected] ~]# ls -l mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -rw-r--r--. 1 root root 548193637 Dec  4 21:16 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz

3、添加mysql使用者和組

[[email protected] ~]# groupadd mysql[[email protected] ~]# useradd -r -g mysql -s /bin/false mysql[[email protected] ~]# id mysqluid=996(mysql) gid=1000(mysql) groups=1000(mysql)

4、建立目錄、改屬組及解壓檔案

[[email protected] ~]# mkdir -p /opt/mysql/[[email protected] ~]# mkdir /mysqldata[[email protected] ~]# mv /root/mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz /opt/mysql/[[email protected] ~]# cd /opt/mysql/[[email protected] mysql]# lsmysql-5.7.11-linux-glibc2.5-x86_64.tar.gz[[email protected] mysql]# tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz ......[[email protected] mysql]# mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql5.7.11[[email protected] mysql]# ls -ltotal 535352drwxr-xr-x. 9 7161 wheel      4096 Feb  2  2016 mysql5.7.11-rw-r--r--. 1 root root  548193637 Dec  4 21:16 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz[[email protected] mysql]# chown mysql:mysql -R /opt/mysql/[[email protected] mysql]# chown mysql:mysql -R /mysqldata/

5、初始化庫

[[email protected] mysql]# cd mysql5.7.11/[[email protected] mysql5.7.11]# ./bin/mysqld --initialize --user=mysql --basedir=/opt/mysql/mysql5.7.11/ --datadir=/mysqldata/2016-12-04T13:33:01.318081Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-12-04T13:33:01.729086Z 0 [Warning] InnoDB: New log files created, LSN=457902016-12-04T13:33:02.027182Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2016-12-04T13:33:02.111882Z 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: 2dca0cf3-ba26-11e6-b4ff-080027e818bc.2016-12-04T13:33:02.118970Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.2016-12-04T13:33:02.120080Z 1 [Note] A temporary password is generated for [email protected]: rqwPw!9iNEEP[[email protected] mysql5.7.11]# ls /mysqldata/auto.cnf  ib_buffer_pool  ibdata1  ib_logfile0  ib_logfile1  mysql  performance_schema  sys

注意:root的初始密碼已經在日誌中給出:rqwPw!9iNEEP

在5.7.6之前的版本中使用bin/mysql_install_db --user=mysql初始化庫。

6、啟動MySQL資料庫

#替換系統內建的my.cnf檔案[[email protected] mysql5.7.11]# mv /etc/my.cnf /etc/my.cnf.bak[[email protected] mysql5.7.11]# cp support-files/my-default.cnf /etc/my.cnf#在my.cnf中添加如下兩條[[email protected] mysql5.7.11]# vi /etc/my.cnfbasedir = /opt/mysql/mysql5.7.11datadir = /mysqldata#啟動MySQL[[email protected] mysql5.7.11]# ./bin/mysqld_safe --user=mysql &[1] 1756[[email protected] mysql5.7.11]# 2016-12-04T13:44:30.046089Z mysqld_safe Logging to ‘/mysqldata/rhel7.err‘.2016-12-04T13:44:30.097978Z mysqld_safe Starting mysqld daemon with databases from /mysqldata[[email protected] mysql5.7.11]# ps -ef |grep mysqlroot      1756  1182  0 21:44 pts/0    00:00:00 /bin/sh ./bin/mysqld_safe --user=mysqlmysql     1876  1756  1 21:44 pts/0    00:00:00 /opt/mysql/mysql5.7.11/bin/mysqld --basedir=/opt/mysql/mysql5.7.11 --datadir=/mysqldata --plugin-dir=/opt/mysql/mysql5.7.11/lib/plugin --user=mysql --log-error=/mysqldata/rhel7.err --pid-file=/mysqldata/rhel7.pidroot      1905  1182  0 21:44 pts/0    00:00:00 grep --color=auto mysql

7、登入MySQL,使用安裝時給出密碼登入並更改root密碼

[[email protected] mysql5.7.11]# ./bin/mysql -uroot -p Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.11Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> set password=‘1qaz!QAZ‘;Query OK, 0 rows affected (0.01 sec)

注意:5.6之前使用set password=password(‘newpassword‘)進行改密碼,5.7版本不再建議這樣改密碼,會有如下提示:

mysql> set password=password(‘123456‘);Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> show warnings;+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Level   | Code | Message                                                                                                                                                           |+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Warning | 1287 | ‘SET PASSWORD = PASSWORD(‘<plaintext_password>‘)‘ is deprecated and will be removed in a future release. Please use SET PASSWORD = ‘<plaintext_password>‘ instead |+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)

到此,MySQL5.7.11安裝完成。

官方文檔:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html


本文出自 “DBA Fighting!” 部落格,請務必保留此出處http://hbxztc.blog.51cto.com/1587495/1879396

RHEL 7.2 安裝 MySQL 5.7.11 二進位版

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.