centos7 國內鏡像yum安裝mysql5.7

http://www.javashuo.com/article/p-sriaorez-nv.htmlhtml

檢查mysql環境是否已存在

雖然個人是純淨系統,但別人的不能保證,爲了不發生什麼問題咱們仍是先檢查下mysql是否已經安裝過mysql

[root@localhost ~] # rpm -qa | grep mysql [root@localhost ~]# rpm -qa |grep mariadb mariadb-libs-5.5.64-1.el7.x86_64

我這裏要卸載mariadbsql

[root@localhost ~]# yum remove mariadb-libs-5.5.64-1.el7.x86_64

假如你發現相似的就和我同樣刪除就行了數據庫

切換阿里雲鏡像源

先安裝wget緩存

[root@localhost ~] # yum install wget -y

而後下載阿里雲yum源配置bash

[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

而後生成緩存ide

[root@localhost ~] # yum makecache

顯視元數據緩存已創建就表明完成了ui

而後咱們更新一下yum阿里雲

[root@localhost ~] # yum update -y

這可能須要一點時間,耐心等待一下spa

下載國內的mysql rpm包並安裝

地址爲http://mirrors.ustc.edu.cn/mysql-ftp/Downloads
我這裏直接經過下載地址下載

先是server包

[root@localhost ~] # wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.32-1.el7.x86_64.rpm

而後是client包

wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.32-1.el7.x86_64.rpm

還有common

[root@localhost ~] # wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.32-1.el7.x86_64.rpm

最後還有一個lib

[root@localhost ~] # wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.32-1.el7.x86_64.rpm

在此以前咱們還要先安裝三個依賴環境
net-tools.x86_64,libaio.x86_64,perl.x86_64

咱們直接使用yum安裝

yum install -y perl.x86_64 yum install -y libaio.x86_64 yum install -y net-tools.x86_64

而後按照順序安裝mysql的依賴

[root@localhost ~]# rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm

而後咱們重啓下mysql服務

[root@localhost ~] # service mysqld.service restart

咱們查看下默認密碼

[root@localhost etc] # grep 'temporary password' /var/log/mysqld.log
2020-02-11T09:49:32.224110Z 1 [Note] A temporary password is generated for root@localhost: E;#ySql0!>

個人密碼爲 E;#ySql0!>

[root@localhost mysql] # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.7.25 Copyright (c) 2000, 2019, 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>

登陸成功,接着改下密碼和遠程鏈接

修改密碼並開啓遠程鏈接

修改密碼

這裏由於mysql的新版本限制了密碼複雜度,因此咱們須要設置一個稍微複雜的密碼

mysql> set password=password('這裏輸入你想改的密碼'); Query OK, 0 rows affected, 1 warning (0.00 sec)

密碼須要包含數字和特殊符號,以及大寫字母和小寫字母
固然你設置完成之後能夠就將密碼限制關閉後在從新改密碼,這裏不過多演示

開啓遠程鏈接

打開mysql數據庫

mysql> use mysql;

修改一條數據使其支持遠程鏈接

mysql> update user set Host = '%' where Host = 'localhost' and User='root';

刷新系統權限相關表

mysql> flush privileges;
相關文章
相關標籤/搜索