我這裏是採用純淨的系統,剛裝的centos7,並且選擇的最小安裝因此基本上是什麼環境都沒有的,而後這篇文章主要針對於小白mysql
雖然個人是純淨系統,但別人的不能保證,爲了不發生什麼問題咱們仍是先檢查下mysql是否已經安裝過sql
[root@localhost ~]# rpm -qa | grep mysql [root@localhost ~]# rpm -qa |grep mariadb mariadb-libs-5.5.64-1.el7.x86_64
我這裏要卸載mariadbshell
[root@localhost ~]# yum remove mariadb-libs-5.5.64-1.el7.x86_64
假如你發現相似的就和我同樣刪除就行了數據庫
先安裝wgetcentos
[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
顯視元數據緩存已創建就表明完成了centos7
而後咱們更新一下yumrest
[root@localhost ~]# yum update -y
這可能須要一點時間,耐心等待一下code
地址爲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.25-1.el7.x86_64.rpm
而後是client包
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.25-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.25-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.25-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.25-1.el7.x86_64.rpm [root@localhost ~]# rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm [root@localhost ~]# rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm [root@localhost ~]# rpm -ivh mysql-community-server-5.7.25-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;#ySHlql0!>
個人密碼爲 E;#ySHlql0!>
[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;
咱們用navicat測一下
在此以前請確保防火牆開放了3306端口
我這裏直接一次過了
關於開機自啓,這種狀況下mysql是自動啓動的,不須要多餘的配置