Linux(CentOS)環境下安裝MySQL
阿新 • • 發佈:2019-02-19
本機需要連線網際網路(後面例項是以線上安裝為例)
1、 在MySQL官網下載yum安裝源(儲存到CentOS7.0系統路徑(桌面\Software))
https://dev.mysql.com/downloads/repo/yum/
下載名稱:
Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package | 1. 9.0K |
(mysql57-community-release-el7-9.noarch.rpm) |
2、 新增下載的yum源(可用命令localinstall/install),進入資料夾Software,輸入以下命令
[root@localhost Software]# yum install -ymysql57-community-release-el7-9.noarch.rpm
3、 安裝MySQL(檢查啟用可安裝程式元件)
[root@localhost Software]# yum repolist all | grep mysql
[root@localhost Software]# yum install -y mysql-community-server
4、 啟動MySQL服務
[root@localhost Software]# service mysqld start
5、 檢視root臨時密碼
[root@localhost Software]# grep "password"/var/log/mysqld.log
2017-02-05T09:22:20.086699Z 1 [Note] A temporary passwordis generated for root@localhost: 9j6srtfRp>;D
6、 測試連線
5.1、連線MySQL(輸入密碼直接右健貼上,回車健確認)
[root@localhostSoftware]# mysql -u root -p
Enter password: 9j6srtfRp>;D
5.2、測試連線效果
以下提示需要重置密碼才能操作
mysql>show databases
-> ;
ERROR 1820 (HY000): You must reset your password usingALTER USER statement before executing this statement.
mysql>set password for 'root'@'localhost'=password('輸入root新密碼');
Query OK,0 rows affected, 1 warning (0.00 sec)
mysql>use mysql;
Readingtable information for completion of table and column names
You canturn off this feature to get a quicker startup with -A
Databasechanged
mysql>show databases;
+--------------------+
|Database |
+--------------------+
|information_schema |
|mysql |
|performance_schema |
|sys |
+--------------------+
4 rows in set (0.00 sec)
--以上為測試成功連線效果