MySQL安装版本为8.0
https://www.mysql.com/
- MySQL Community Downloads
https://dev.mysql.com/downloads/
- Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package
https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装环境为CentOS7
[root@localhost vagrant]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost vagrant]# uname -a
Linux localhost.localdomain 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
使用wget下载并安装MySQL官方的 Yum Repository
[root@localhost vagrant]# mkdir mysql
[root@localhost vagrant]# cd mysql/
[root@localhost mysql]# yum install wget -y //安装wget
...
[root@localhost mysql]# wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
...
[root@localhost mysql]# ls
mysql80-community-release-el7-3.noarch.rpm
[root@localhost mysql]# rpm -i mysql80-community-release-el7-3.noarch.rpm
warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
安装MySQL80
[root@localhost mysql]# yum search mysql-community-server
mysql-community-server.x86_64 : A very fast and reliable SQL database server
[root@localhost mysql]# yum install mysql-community-server.x86_64 //等待MySQL安装完成
初始化MySQL80
//mysql80在完成初始化之后无法修改大小写忽略的配置 只能在初始化之前设置
//第一种方式
[root@localhost mysql]# /usr/sbin/mysqld --initialize --user=mysql --lower-case-table-names=1
//第二种方式 推荐 使用vim修改、etc/my.cnf文件 lower-case-table-names=1
[root@localhost mysql]# yum install vim -y
[root@localhost mysql]# vim /etc/my.cnf //添加lower-case-table-names=1
启动MySQL80
[root@localhost mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
//如果mysql启动失败, 可以删除/var/lib/mysql文件夹重新启动
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-01-12 16:00:41 UTC; 9s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2135 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2207 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─2207 /usr/sbin/mysqld
查看MySQL80中Root角色初始密码
[root@localhost mysql]# cat /var/log/mysqld.log | grep password
连接到MySQL80
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22
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>