https://www.cnblogs.com/ccsert/p/12296213.html
檢查mysql環境是否已存在
雖然我的是純凈系統,但別人的不能保證,為了避免發生什么問題我們還是先檢查下mysql是否已經安裝過
[root@localhost ~]# rpm -qa | grep mysql [root@localhost ~]# rpm -qa |grep mariadb mariadb-libs-5.5.64-1.el7.x86_64我這里要卸載mariadb
[root@localhost ~]# yum remove mariadb-libs-5.5.64-1.el7.x86_64假如你發現類似的就和我一樣洗掉就好了
切換阿里云鏡像源
先安裝wget
[root@localhost ~]# yum install wget -y然后下載阿里云yum源配置
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo然后生成快取
[root@localhost ~]# yum makecache顯視元資料快取已建立就代表完成了
然后我們更新一下yum
[root@localhost ~]# yum update -y這可能需要一點時間,耐心等待一下
下載國內的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;轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/208668.html
標籤:MySQL
下一篇:Redis(一)
