截至发稿,MySQL 的最新小版本号为:MySQL Installer 8.0.27。
(see: https://dev.mysql.com/downloads/ )
分 linux 和 windows 两个环境
Linux 环境(CentOS)
到官网找到对应版本的 yum 文件,地址:
https://dev.mysql.com/downloads/repo/yum/
以 CentOS 7 为例,下载如下文件:
wget https://dev.mysql.com/get/mysql80-community-release-el7-4.noarch.rpm
执行:
rpm -ivh mysql80-community-release-el7-4.noarch.rpm
随后可以安装:
yum updateyum -y install mysql-community-server
MySQL 8.0,会在安装后第一次启动为你生成一个密码,查看密码:
grep "password" /var/log/mysqld.log
注意:如果遇到没有密码,请重启下mysql
[aaron@micrograils.com bin]$ sudo grep password /var/log/mysqld.log2021-11-15T22:42:20.744054Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: V(hE/t,tJ0?7[aaron@micrograils.com bin]$
登录进去,执行任何语句时都会提醒你要修改初始密码:
[aaron@micrograils.com bin]$ mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 22Server version: 8.0.27 MySQL Community Server - GPLCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
mysql> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql>
# 强密码生成网址:
https://1password.com/zh-cn/password-generator/
修改初始密码(纯字母数字组合不行):
mysql> alter user 'root'@'localhost' identified by 'UpgWZZUMEqnQPgd3Xa3A';ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsmysql> alter user 'root'@'localhost' identified by 'K=~TLB6of.BLa6o_,Abs';Query OK, 0 rows affected (0.01 sec)mysql>
Windows 环境
官方下载地址:
https://dev.mysql.com/downloads/
如果下安装版本(470M),下载后一路双击即可:
https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.27.1.msi
如下载 zip 版(209M),地址:
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.27-winx64.zip
下载后解压,建议路径不包含中文:
C:\Users\Aaron>d:D:\>cd dev_env\mysql\binD:\dev_env\mysql\bin>
初始化数据库
mysqld --initialize --console
安装
mysqld install
启动
net start mysql
文章转载自MicroGrails,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




