CentOS7安裝Mysql5.7

1. 查看是否有mariadb,有就刪除掉,請自行了解mariadb。
[root@VM_195_230_centos upload]# rpm -qa|grep mariadb
mariadb-libs-5.5.50-1.el7_2.x86_64
[root@VM_195_230_centos upload]# rpm -e mariadb-libs-5.5.50-1.el7_2.x86_64 --nodeps
[root@VM_195_230_centos upload]# rpm -qa|grep mariadb
2. 下載mysql5.7,會花費必定時間。
[root@VM_195_230_centos upload]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
......
2017-06-13 15:35:16 (1.08 MB/s) - 'mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar' saved [569978880/569978880]
3. 檢看下載好的文件,並解壓
[root@VM_195_230_centos upload]# ls 
mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
[root@VM_195_230_centos upload]# tar xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 
mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
mysql-community-libs-5.7.16-1.el7.x86_64.rpm
mysql-community-common-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-test-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-community-client-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-5.7.16-1.el7.x86_64.rpm
[root@VM_195_230_centos upload]# ls
mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-5.7.16-1.el7.x86_64.rpm
mysql-community-common-5.7.16-1.el7.x86_64.rpm
mysql-community-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm
mysql-community-libs-5.7.16-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
mysql-community-test-5.7.16-1.el7.x86_64.rpm
mysql57-community-release-el7-11.noarch.rpm
4. 安裝mysql-community-common
[root@VM_195_230_centos upload]# sudo rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm 
warning: mysql-community-common-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.16-1.e################################# [100%]
5. 安裝mysql-community-libs
[root@VM_195_230_centos upload]# sudo rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.16-1.el7################################# [100%]
6. 安裝mysql-community-client
[root@VM_195_230_centos upload]# sudo  rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm 
warning: mysql-community-client-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.16-1.e################################# [100%]
7. 安裝mysql-community-server,可是可能會出現錯誤,安裝net-tools、libaio和numactl便可
[root@VM_195_230_centos upload]# sudo rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
[root@VM_195_230_centos upload]# sudo yum install net-tools
......
[root@VM_195_230_centos upload]# sudo yum install libaio
......
[root@VM_195_230_centos upload]# sudo rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
[root@VM_195_230_centos upload]# sudo yum install numactl
......
[root@VM_195_230_centos upload]# sudo rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.16-1.e################################# [100%]
8. 運行mysqld,並查看其進程
[root@VM_195_230_centos upload]# mysqld 
2017-06-13T07:39:52.430464Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-13T07:39:52.432444Z 0 [Note] mysqld (mysqld 5.7.16) starting as process 31404 ...
2017-06-13T07:39:52.435516Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!node

2017-06-13T07:39:52.435545Z 0 [ERROR] Abortingmysql

2017-06-13T07:39:52.435562Z 0 [Note] Binlog end
2017-06-13T07:39:52.435759Z 0 [Note] mysqld: Shutdown completesql

[root@VM_195_230_centos upload]# ps -ef | grep mysqld
root     31455 29805  0 15:40 pts/0    00:00:00 grep --color=auto mysqld
9. 初始化mysql數據
[root@VM_195_230_centos upload]# mysqld --initialize --user=mysql
10. 查看自動生成的密碼,在/var/log/mysqld.log文件的最後
[root@VM_195_230_centos upload]# cat /var/log/mysqld.log
2017-06-13T07:40:13.944867Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-13T07:40:14.337013Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-06-13T07:40:14.434155Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-06-13T07:40:14.492185Z 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: 89cddc6c-500b-11e7-af19-525400cfcfdb.
2017-06-13T07:40:14.493954Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-06-13T07:40:14.494419Z 1 [Note] A temporary password is generated for root@localhost: HuWi7aT#fAUO
11. 啓動mysqld
[root@VM_195_230_centos upload]#  systemctl start mysqld.service
12. 登陸mysql,注意不能粘貼密碼,須要手動輸入
[root@VM_195_230_centos upload]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16數據庫

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.centos

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.ide

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.this

13. 查看數據庫,系統提示要修改密碼
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'qwerasdf1234';
Query OK, 0 rows affected (0.00 sec)debug

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)orm

14. 完成。server

PS:資源來源於互聯網,本身只提取並整理出了核心的東西。

相關文章
相關標籤/搜索