這段時間在安裝mysql時候遇到點問題,原先的yum安裝安裝不上,於是自己采用rpm安裝mysql;
mysql需要的rpm包下載地址:http://repo.mysql.com/yum/
選擇你自己想要安裝的版本,打開之后會是這樣的。

1. 首先清除centos7系統中默認的數據庫mariadb,否則不能安裝mysql。
rpm -qa |grep mariadb |xargs yum remove -y
2.下載mysql的相關rpm包

關於下載問題,你可以直接使用wget + 包的URL 下載到一個臨時文件(我的是/tmp/download文件)

注意:每個安裝包版本號是一樣的,否則后面安裝會出現問題;意味着每個文件都是以5.7.19-1.el7.x86_64.rpm結尾的
3.切換到下載包目錄下(cd 你的下載目錄),然后對每個包進行一次安裝;
rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm
在安裝最后一個mysql-community-server的時候可能會出現下面的錯誤提示:

解決這個問題是因為系統缺少了libaio這個庫,我們安裝好就可以了。
下載地址:http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
這時候就可以安裝mysql-community-server;
4.查看安裝mysql時候生成的臨時密碼,這個臨時密碼放在了mysql日志文件中了。(對於Mysql 5.7.6以后的5.7系列版本,Mysql使用mysqld --initialize或mysqld --initialize-insecure命令來初始化數據庫,后者可以不生成臨時密碼。)
[root@localhost ~]# cat /etc/my.cnf
log-error=/var/log/mysqld.log --找到日志路徑
[root@localhost ~]# cat /var/log/mysqld.log | grep password --查到密碼為PCbu?SNEx8zl
[root@localhost ~]# /usr/bin/mysql_secure_installation --安裝完mysql后執行自帶的安全設置
Securing the MySQL server deployment. Enter password for user root: --輸入剛找到的臨時密碼 The existing password for the user account root has expired. Please set a new password. New password: --設置新的密碼 Re-enter new password: The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y --移除匿名用戶 Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y --不允許遠程連接 Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y --移除測試數據庫 - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y --重讀授權表使前面修改生效 Success. All done!
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (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.
mysql>
5. 安裝成功!
