CentOS7安裝mysql8.0.12版本

1、下載MySQL源安裝包並安裝

MySQL源安裝包下載鏈接

[root@ chenc01 ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@ chenc01 ~]# yum localinstall mysql80-community-release-el7-1.noarch.rpm

2、檢查是否安裝成功

[root@ chenc01 ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                 141
mysql-tools-community/x86_64      MySQL Tools Community                      105
mysql80-community/x86_64          MySQL 8.0 Community Server                 161

3、安裝mysql

[root@ chenc01 ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror
base                                                                                 | 3.6 kB  00:00:00     
epel                                                                                 | 5.3 kB  00:00:00     
extras                                                                               | 2.9 kB  00:00:00     
mysql-connectors-community                                                           | 2.5 kB  00:00:00     
mysql-tools-community                                                                | 2.5 kB  00:00:00     
mysql55-community                                                                    | 2.5 kB  00:00:00     
updates                                                                              | 2.9 kB  00:00:00     
mysql55-community/x86_64/primary_db                                                  | 183 kB  00:00:00     
Loading mirror speeds from cached hostfile

4、啓動mysql服務

1)啓動

[root@ chenc01 ~]# systemctl start mysqld

2)查看啓動狀態

[root@ chenc01 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-03-16 18:17:59 CST; 39s ago
  Process: 2003 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 1949 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 2002 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ├─2002 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─2161 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/...

3)設置開機啓動

[root@ chenc01 ~]# systemctl enable mysqld
Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mysqld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.

4)啓動MySQL

注意MySQL8.0.19 的登錄密碼是自動生成的!

[root@ chenc01 ~]# grep 'temporary password' /var/log/mysqld.log
2020-03-16T10:33:27.273294Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: eRxeGx_AO5nZ
[root@ chenc01 ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.19

Copyright (c) 2000, 2020, 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> 

5)修改MySQL登錄密碼

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'TestBicon@123';
Query OK, 0 rows affected (0.01 sec)
mysql> 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章