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!2017-06-13T07:39:52.435545Z 0 [ERROR] Aborting
2017-06-13T07:39:52.435562Z 0 [Note] Binlog end
2017-06-13T07:39:52.435759Z 0 [Note] mysqld: Shutdown complete[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.16Copyright (c) 2000, 2016, 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.
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)mysql> show databases;
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)14. 完成。
PS:资源来源于互联网,自己只提取并整理出了核心的东西。