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;