Linux安裝mysql5.7

1、查看是否安裝歷史版本
# 查看
rpm -qa|grep mysql
rpm -qa|grep mariadb
# 卸載
yum -y remove  #mysql安裝包名稱
yum -y remove  #mariadb安裝包名稱
2、下載安裝
[root@localhost ~]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
[root@localhost ~]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
[root@localhost ~]# yum install -y mysql mysql-server
[root@localhost ~]# mysql -V   //查看當(dāng)前安裝mysql版本
mysql  Ver 14.14 Distrib 5.7.27, for Linux (x86_64) using  EditLine wrapper
3、修改密碼
[root@localhost ~]# systemctl start mysqld   //啟動mysql服務(wù)
[root@localhost ~]# grep "password" /var/log/mysqld.log  //通過log查看初始密碼
2021-08-05T16:17:00.010786Z 1 [Note] A temporary password is generated for root@localhost: i0d?ur_#rr+O0    //i0d?ur_#rr+O0此為mysql初始密碼
[root@localhost ~]# mysql -u root -p  
Enter password:                         //輸入初始密碼i8d?ur_#rr+O
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27
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> alter user 'root'@'localhost' identified by 'Password';   //重置mysql密碼為:Password
Query OK, 0 rows affected (0.00 sec)

mysql> update mysql.user set host='%' where host='localhost';  //root用戶可使用任意IP登錄數(shù)據(jù)庫
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges;   //刷新權(quán)限
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1.下載MySQL yum 源 mysql yum 源下載image.png我是centos6,下載的對應(yīng)版本的y...
    惜_5ca5閱讀 931評論 0 0
  • mysql安裝排坑,不同版本可能會使用命令不同,這里需要謹(jǐn)慎查閱。 1. 按照需求在mysql官網(wǎng)下載對應(yīng)linu...
    司夜_崔閱讀 162評論 0 1
  • 安裝mysql新命令 CentOS7安裝MySQL 在CentOS中默認(rèn)安裝有MariaDB,這個是MySQL的...
    IT男的假智慧閱讀 104評論 0 0
  • 一、檢查是否已經(jīng)安裝過MySQL 二、檢查用戶名和用戶組是否已經(jīng)創(chuàng)建,沒有就創(chuàng)建 三、/usr/local/目錄下...
    皮蛋餡兒閱讀 327評論 0 1
  • 前言 想在自己的服務(wù)器上創(chuàng)建數(shù)據(jù)庫,這里我通過XShell遠(yuǎn)程連接公司內(nèi)網(wǎng)機(jī)器。如果是自己的服務(wù)器,可以直接連接,...
    _52Hertz閱讀 5,146評論 5 1

友情鏈接更多精彩內(nèi)容