linux上安裝mysql

kakaxi9521發表於2020-10-13

os:         CentOS Linux release 7.7.1908 (Core)

mysql:   Mysql5.7.21


1. 下載安裝包:

[root@localhost rpm]# ls -l

total 461684

-rw-r--r-- 1 root root  23850100 Oct 13 15:13 mysql-community-client-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root    337036 Oct 13 15:13 mysql-community-common-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root   3721376 Oct 13 15:13 mysql-community-devel-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root  39214116 Oct 13 15:13 mysql-community-embedded-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root 136516836 Oct 13 15:13 mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root   2177444 Oct 13 15:13 mysql-community-libs-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root   1723492 Oct 13 15:13 mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root 159856456 Oct 13 15:13 mysql-community-server-5.7.21-1.el6.x86_64.rpm

-rw-r--r-- 1 root root 105350080 Oct 13 15:13 mysql-community-test-5.7.21-1.el6.x86_64.rpm

2. 批次安裝Mysql安裝包:

[root@localhost rpm]# rpm -Uvh *.rpm --nodeps --force

warning: mysql-community-client-5.7.21-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-common-5.7.21-1.e################################# [ 10%]

   2:mysql-community-libs-5.7.21-1.el6################################# [ 20%]

   3:mysql-community-client-5.7.21-1.e################################# [ 30%]

   4:mysql-community-server-5.7.21-1.e################################# [ 40%]

   5:mysql-community-devel-5.7.21-1.el################################# [ 50%]

   6:mysql-community-embedded-5.7.21-1################################# [ 60%]

   7:mysql-community-embedded-devel-5.################################# [ 70%]

   8:mysql-community-test-5.7.21-1.el6################################# [ 80%]

   9:mysql-community-libs-compat-5.7.2################################# [ 90%]

Cleaning up / removing...

  10:mariadb-libs-1:5.5.64-1.el7      ################################# [100%]

3. 檢查安裝包:

[root@localhost rpm]# rpm -qa | grep mysql 

mysql-community-client-5.7.21-1.el6.x86_64

mysql-community-embedded-devel-5.7.21-1.el6.x86_64

mysql-community-libs-5.7.21-1.el6.x86_64

mysql-community-server-5.7.21-1.el6.x86_64

mysql-community-embedded-5.7.21-1.el6.x86_64

mysql-community-test-5.7.21-1.el6.x86_64

mysql-community-common-5.7.21-1.el6.x86_64

mysql-community-devel-5.7.21-1.el6.x86_64

mysql-community-libs-compat-5.7.21-1.el6.x86_64

4. 修改my.cnf

按照需求修改mysql資料目錄及新增其他引數。

5.初始化Mysql例項

[root@localhost mysql]# service mysqld start

Starting mysqld (via systemctl):                           [  OK  ]

6.修改root密碼

[root@localhost log]# cat mysqld.log | grep password

2020-10-13T07:45:47.532299Z 1 [Note] A temporary password is generated for root@localhost: u&r-xf+Zh9Wn

2020-10-13T07:45:51.454915Z 2 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO)

mysql> set password = password("M_123456");

Query OK, 0 rows affected, 1 warning (0.00 sec)





來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21374452/viewspace-2726618/,如需轉載,請註明出處,否則將追究法律責任。

相關文章