1、前言
開源中國介紹文檔:MySQL 8.0 正式版 8.0.11 發佈:比 MySQL 5.7 快 2 倍
2、開始
1、準備
首先你得登陸到自己的服務器。
2、獲取MySQL最新版 rpm包 集合 的下載地址(獲取最新版MySQL下載地址方法)
MySQL下載頁面:https://dev.mysql.com/downloads/mysql/8.0.html
我是CentOS系統 所以 我選擇了 Red Hat。
第一個爲一個 tar歸檔包,裏面是 後面所有 rpm 的打包(仔細看後面都是rpm 結尾的)
點擊右邊Download
這就是最新版 MySQL資源鏈接 :https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
3、wget下載到服務器
我下載到 /tmp 目錄下了。回車開始下載。
4、解壓MySQL歸檔包
tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
5、開始安裝
1、當中會遇到的問題
1、mysql-community-libs .... 這兩個包安裝不上。
原因:我們在Linux系統中,如果要使用關係型數據庫的話,基本都是用的mysql。
而且以往7以下版本的centos系統都是默認的集成有mysql。
然而對於現在最新的centos7系統來說,已經不支持mysql數據庫,它默認內部集成了mariaDB。
如果我們想要使用 mysql 的話,就要先將原來的mariaDB卸載掉,不然會引起衝突。
解決方案:卸載maridb (rpm 不會卸載軟件的 自行百度)
查看安裝的 mariaDB:rpm -qa | grep mariadb
卸載:rpm -e ***(*** 爲軟件名)
如果不能卸載則即可:rpm -e --nodeps ***(*** 爲軟件名)
2、缺少依賴包 libaio
libaio.so.1()(64bit) is needed by MySQL-server 問題
直接實用yum包管理工具安裝即可:yum install libaio
2、使用 rpm -vih XXXXXX(XXXXXX 爲 rpm包全名)
按照依賴順序依次安裝(能安裝的安裝就行,像test這個不方便安裝就算了。)
mysql-community-common-8.0.13-1.el7.x86_64
mysql-community-libs-8.0.13-1.el7.x86_64
mysql-community-libs-compat-8.0.13-1.el7.x86_64
mysql-community-client-8.0.13-1.el7.x86_64
mysql-community-embedded-compat-8.0.13-1.el7.x86_64
6、啓動MySQL服務,並設置root密碼
1、啓動mysql服務
service mysqld restart
2、初次安裝mysql,root賬戶沒有密碼。
[root@izuf6 tmp]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
rows in set (0.01 sec)
mysql>
設置密碼:
mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)
mysql>
不需要重啓數據庫即可生效。
3、使用樣例
7、MySQL一些騷炒作
-- 登錄sys數據庫
mysql -u root -proot sys
-- 查看所有的數據庫
select database()
-- 查看數據庫
show databases;
-- 模糊查詢包含y的數據庫
show databases like '%y%';
-- 查看錶
show tables;
--模糊查詢包含user的表
show tables like '%user%';
-- 查看列, 查看user表信息
desc user;