CentOS6離線安裝mysql-5.7.25


1.mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar下載百度雲資源

百度雲:https://pan.baidu.com/s/1Sfom_aNhTyZnR7KGTZIfFw      

提取碼:ej1y

 

2.把下載的mysql安裝包上傳到Centos上

解壓mysql,我這是在Windows上解壓的上傳到Centos上,我在Centos上解壓mysql不知道為什么少了rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm包

tar –vxf mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar

 

3.查看mysql依賴

rpm -qa | grep mysql

  

4.如果查看有mysql依賴,就刪除mysql依賴,

rpm -e --nodeps `rpm -qa | grep mysql`

 

5.再次查是否有mysql依賴

rpm -qa | grep mysql

  

6.安裝一定要按照順序來

第一個安裝:  rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm報了一個錯誤

[root@localhost mysql-5.7.25]# rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm 
warning: mysql-community-common-5.7.25-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
        file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/armscii8.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/ascii.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1250.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1251.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1256.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1257.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp850.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp852.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp866.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/dec8.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/geostd8.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/greek.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/hebrew.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/hp8.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/koi8r.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/koi8u.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin1.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin2.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin5.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin7.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/macce.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/macroman.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
        file /usr/share/mysql/charsets/swe7.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
[root@localhost mysql-5.7.25]# file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.25-1.el6.x86_64 conflicts with file from package MariaDB-common-10.4.8-1.el7.centos.x86_64
/usr/share/mysql/charsets/Index.xml:        XML  document text
from:                                       cannot open `from' (No such file or directory)
install:                                    cannot open `install' (No such file or directory)
of:                                         cannot open `of' (No such file or directory)
mysql-community-common-5.7.25-1.el6.x86_64: cannot open `mysql-community-common-5.7.25-1.el6.x86_64' (No such file or directory)
conflicts:                                  cannot open `conflicts' (No such file or directory)
with:                                       cannot open `with' (No such file or directory)
file:                                       cannot open `file' (No such file or directory)
from:                                       cannot open `from' (No such file or directory)
package:                                    cannot open `package' (No such file or directory)
MariaDB-common-10.4.8-1.el7.centos.x86_64:  cannot open `MariaDB-common-10.4.8-1.el7.centos.x86_64' (No such file or directory)

原因:已存在MariaDB-common-10.4.8-1.el7.centos.x86_64的庫(這是我以前安裝MariaDB數據庫,如果是別的也要根據對應的名字刪除),所以需要先刪除以前的庫才能安裝!

執行強制卸載命令:

rpm -e MariaDB-common-10.4.8-1.el7.centos.x86_64--nodeps

 

然后查看:

rpm –qa | grep mysql

  

再繼續安裝

rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm
[root@localhost mysql-5.7.25]# rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm 
warning: mysql-community-common-5.7.25-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-common ########################################### [100%]

  

第二個安裝:

rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm
[root@localhost mysql-5.7.25]# rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm 
warning: mysql-community-libs-5.7.25-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-libs   ########################################### [100%]

  

第三個安裝

rpm -ivh mysql-community-client-5.7.25-1.el6.x86_64.rpm
[root@localhost mysql-5.7.25]# rpm -ivh mysql-community-client-5.7.25-1.el6.x86_64.rpm 
warning: mysql-community-client-5.7.25-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-client ########################################### [100%]

  

第四個安裝

rpm -ivh mysql-community-server-5.7.25-1.el6.x86_64.rpm
[root@localhost mysql-5.7.25]# rpm -ivh mysql-community-server-5.7.25-1.el6.x86_64.rpm 
warning: mysql-community-server-5.7.25-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-server ########################################### [100%]
You have new mail in /var/spool/mail/root

 

第五個安裝

rpm -ivh mysql-community-devel-5.7.25-1.el6.x86_64.rpm
[root@localhost mysql-5.7.25]# rpm -ivh mysql-community-devel-5.7.25-1.el6.x86_64.rpm 
warning: mysql-community-devel-5.7.25-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-devel  ########################################### [100%]

  

7.使用命令啟動mysql服務

service mysqld start
[root@localhost mysql-5.7.25]# service mysqld start
Starting mysqld:  [  OK  ]
[root@localhost mysql-5.7.25]#

  

8.使用命令生成一個隨機密碼:grep "temporary password" /var/log/mysqld.log

[root@localhost mysql-5.7.25]# grep "temporary password" /var/log/mysqld.log
2020-04-07T12:32:39.276158Z 1 [Note] A temporary password is generated for root@localhost: >v>uyo:fg7.O
[root@localhost mysql-5.7.25]#

注意:密碼是root@localhost:右邊的字符串

root@localhost: >v>uyo:fg7.O   這里生成的隨機密碼是:>v>uyo:fg7.O

MySQL 會在 /var/log/mysqld.log 日志中生成一個隨機密碼,默認需要修改密碼才能使用

 

可以通過 vim  /var/log/mysqld.log 打開里面有一行這樣的代碼

2020-04-07T12:32:39.276158Z 1 [Note] A temporary password is generated for root@localhost: >v>uyo:fg7.O

 

9.修改密碼,先登錄mysql

mysql -u root –p
[root@localhost mysql-5.7.25]# mysql -u root -p
Enter password:

我這隨機密碼就是:>v>uyo:fg7.O 

 

10.登錄成功

[root@localhost log]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'wangqing';
Query OK, 0 rows affected (0.01 sec)

mysql>

  

11.修改密碼:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密碼';

  

12.設置權限

  為了可以遠程連接該數據庫,需要設置相應的權限

  

#任何主機
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '剛剛修改的密碼' WITH GRANT OPTION;
#指定主機
mysql>GRANT ALL PRIVILEGES ON *.* TO 'xxxx'@’xx.xx.xx.xx’ IDENTIFIED BY 'xxxx' WITH GRANT OPTION;

  

13.刷新權限

mysql>flush privileges;

 

這就完成了,可以用sql工具連接mysql了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM