Linux CentOS7 YUM 安裝mysql5.7

一、安裝YUM Repo

1. 先查看 是否存在 MySQL 存在要刪除

如:

 先查看已經安裝的rpm包
rpm -qa|grep mysql
mysql-libs-5.1.73-8.el6_8.x86_64
mysql80-community-release-el7-1.noarch

 卸載上一步得到的兩個rpm包
yum remove mysql-libs-5.1.73-8.el6_8.x86_64
yum remove mysql80-community-release-el7-1.noarch

2.由於CentOS 的yum源中沒有mysql,需要到mysql的官網下載yum repo配置文件。

下載命令:

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

在這裏插入圖片描述
在這裏插入圖片描述

3.然後進行repo的安裝:

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

執行完成後會在/etc/yum.repos.d/目錄下生成兩個repo文件mysql-community.repo mysql-community-source.repo

在這裏插入圖片描述

二、使用yum命令即可完成安裝

注意:必須進入到 /etc/yum.repos.d/目錄後再執行以下腳本

1.安裝命令:

yum install mysql-server

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

2.啓動msyql:

systemctl start mysqld #啓動MySQL

3.獲取安裝時的臨時密碼(在第一次登錄時就是用這個密碼):

grep 'temporary password' /var/log/mysqld.log

4.倘若沒有獲取臨時密碼,則
4.1 刪除原來安裝過的mysql殘留的數據

rm -rf /var/lib/mysql

4.2.再啓動mysql

systemctl start mysqld #啓動MySQL

三、登錄數據庫

1.mysql -uroot -p  # 第一次登錄 使用默認密碼 回車之後 輸入默認密碼
2.首先登錄MySQL。 
格式:mysql> set password for 用戶名@localhost = password('新密碼'); 
例子:mysql> set password for root@localhost = password('123'); 

可能會遇到的問題:
**1.**ERROR 1819 (HY000): Your password does not satisfy the current policy requirements_Spring Boot-Common On With You-CSDN博客
*參考:
https://blog.csdn.net/hello_world_qwp/article/details/79551789

2.mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
參考:
【mysql】You must reset your password using ALTER USER statement before executing this statement. 報錯處理 - faith丶 - 博客園
https://www.cnblogs.com/faithH/p/11821114.html

3.開放遠程登錄

use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456'; # 這裏的123456爲你給新增權限用戶設置的密碼,%代表所有主機,也可以具體到你的主機ip地址
flush privileges;#  這句表示從mysql數據庫的grant表中重新加載權限數據
select  host,user  from user; #   查詢是否設置成功

MySQL修改初始密碼三種方法:_許恆的博客-CSDN博客 https://blog.csdn.net/xuheng8600/article/details/80034647

【mysql】You must reset your password using ALTER USER statement before
executing this statement. 報錯處理 - faith丶 - 博客園
https://www.cnblogs.com/faithH/p/11821114.html

ERROR 1819 (HY000): Your password does not satisfy the current policy
requirements
https://blog.csdn.net/hello_world_qwp/article/details/79551789

四、參考鏈接

CentOS7下YUM安裝與配置MySQL5.7
(1條消息)CentOS7下YUM安裝與配置MySQL5.7_Cocoliu的專欄-CSDN博客
https://blog.csdn.net/u010817321/article/details/52765383

Centos7使用yum命令安裝Mysql5.6.X
Centos7使用yum命令安裝Mysql5.6.X - 景嶽 - 博客園
https://www.cnblogs.com/xxoome/p/8313453.html

mysql開啓遠程訪問權限
mysql開啓遠程訪問權限 - liuzp91 - 博客園
https://www.cnblogs.com/lzp91/p/11382147.html

mysql如何修改root用戶的密碼
(1條消息)mysql如何修改root用戶的密碼_含笑的依米的博客-CSDN博客
https://blog.csdn.net/qq_31220649/article/details/89468706

centos7下使用yum安裝mysql
centos7下使用yum安裝mysql - julyme - 博客園
https://www.cnblogs.com/julyme/p/5969626.html

【【有用的linux 安裝 MySQL】】
CentOS7下安裝mysql5.7
(1條消息)CentOS7下安裝mysql5.7_不甘於平凡的潰敗的博客-CSDN博客
https://blog.csdn.net/wohiusdashi/article/details/89358071

CentOS第一次安裝MySQL的完整步驟 - Silentdoer - 博客園
https://www.cnblogs.com/silentdoer/articles/7258232.html

(1條消息)centos7 安裝mysql詳細流程_zxy987872674的博客-CSDN博客
https://blog.csdn.net/zxy987872674/article/details/81949430

MySQL的安裝:
CentOS7下安裝mysql5.7
https://blog.csdn.net/wohiusdashi/article/details/89358071

centos7 安裝MySQL7 並更改初始化密碼
https://www.cnblogs.com/shihuibei/p/9249155.html

Centos7下無法遠程連接mysql數據庫的原因與解決
https://blog.csdn.net/u013257111/article/details/79063578

CentOS7.4用yum安裝並配置MySQL5.7
https://www.cnblogs.com/opsprobe/p/10681063.html

冰戀雲的專欄
https://blog.csdn.net/z13615480737/category_9272707.html?utm_source=BWXQ_bottombtn

CentOS 7 下使用yum安裝MySQL5.7.20 最簡單 圖文詳解 (得花錢)
https://blog.csdn.net/z13615480737/article/details/78906598

CentOS-7 yum 安裝與配置MySQL-5.7
https://blog.csdn.net/github_38336924/article/details/82188860

在linux中,怎樣查看Mysql服務運行狀態?
http://www.imooc.com/wenda/detail/562172

CentOS-7 yum 安裝與配置MySQL-5.7
https://blog.csdn.net/github_38336924/article/details/82188860

CentOS7下安裝mysql5.7
https://blog.csdn.net/wohiusdashi/article/details/89358071

啓動mysql5.7異常The server quit without updating PID file [FAILED]sql/data/***.pi根本解決方案
https://www.cnblogs.com/aeolian/p/10411846.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章