1. 程式人生 > 資料庫 >Centos7安裝Redis單機版

Centos7安裝Redis單機版

1.下載mysql5.7軟體包

1.下載mysql5.7軟體包
下載地址:
https://dev.mysql.com/downloads/repo/yum/
# 下載
shell> wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# 安裝 mysql 源
shell> yum localinstall mysql57-community-release-el7-11.noarch.rpm
 

 

2.檢視mysql是否安裝成功
[root@localhost ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64       MySQL Connectors Community           175
mysql-tools-community/x86_64            MySQL Tools Community                120
mysql57-community/x86_64                MySQL 5.7 Community Server           464
mysql80-community/x86_64                MySQL 8.0 Community Server           211
注:以上mysql源中包括了mysql5.7和mysql8.0這兩個安裝包,如需要下改其他mysql軟體包,如下載mysql5.6等版本需要修改/etc/yum.repos.d/mysql-community.repo配置檔案中的enable選項
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-preview]
name=MySQL Tools Preview
baseurl=http://repo.mysql.com/yum/mysql-tools-preview/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-cluster-7.5-community]
name=MySQL Cluster 7.5 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-cluster-7.6-community]
name=MySQL Cluster 7.6 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-cluster-8.0-community]
name=MySQL Cluster 8.0 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
View Code

2.安裝mysql軟體

安裝mysql5.7軟體
yum install mysql-community-server    -y
啟動服務
systemct  start  mysqld
[root@localhost ~]# mysqld --version
mysqld  Ver 5.7.32 for Linux on x86_64 (MySQL Community Server (GPL))
設定開機自啟動
systemctl enable mysqld
systemctl daemon-reload
注:mysql5.7在安裝後,會/var/log/mysqld.log檔案中給root生成了一個預設密碼。通過下面的方式找到root預設密碼,然後登入mysql進行修改
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2020-12-12T20:36:30.875750Z 1 [Note] A temporary password is generated for root@localhost: Ljy_GM<ws6sh
使用賬戶密碼進行登入資料庫
[root@localhost ~]# mysql  -uroot   -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.32

Copyright (c) 2000, 2020, 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.
............................
注:使用者在第一次登入資料庫時需要進行更改使用者密碼才能操作資料庫

 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ABC_123abc';
 Query OK, 0 rows affected (0.00 sec)

mysql> select version();

+-----------+
| version() |
+-----------+
| 5.7.32 |
+-----------+
1 row in set (0.00 sec)