Windows安装MySQL8(压缩包版)
下载压缩包
mysql社区版压缩包版zip下载地址
mysql社区版安装包版windows安装包下载地址
解压到想要的位置,
此时目录中还没有data文件夹
将解压目录的bin文件夹配置到环境变量的path, 之后执行mysql或mysqld都用得到, 不配置的话,每次进目录执行都麻烦, 而且安装时要用到控制台的系统管理员权限
mysqld --initialize
mysqld -install
net start mysql
mysqld --initialize
和 mysqld --initialize-insecure
mysqld --initialize
mysqld --initialize-insecure
执行 mysqld --initialize
和 mysqld --initialize-insecure
前, 必须没有 data 文件夹 , 否则报错, 执行后会生成data文件夹, 想再次初始化的话必须删除data文件夹
Use --initialize for “secure by default” installation (that is, including generation of a random initial root password). In this case, the password is marked as expired and you must choose a new one.
用 --initialize
会生成随机的初始根密码,密码被标记为过期,必须选择一个新密码。
With --initialize-insecure, no root password is generated. This is insecure; it is assumed that you intend to assign a password to the account in a timely fashion before putting the server into production use.
用 --initialize-insecure
不会为root生成密码, 可以无密码登陆 mysql -uroot
回车 或 mysql -uroot -p
回车回车
用 --initialize
会生成随机的初始根密码, 加 --console
会在控制台输出生成的随机密码
Windows后加 --console
, Linux后加 --user=mysql
官方原文👇
On Unix and Unix-like systems, it is important for the database directories and files to be owned by the mysql login account so that the server has read and write access to them when you run it later. To ensure this, start mysqld from the system root account and include the --user option as shown here:
bin/mysqld --initialize --user=mysql
bin/mysqld --initialize-insecure --user=mysql
Alternatively, execute mysqld while logged in as mysql, in which case you can omit the --user option from the command.
On Windows, use one of these commands:
bin\mysqld --initialize --console
bin\mysqld --initialize-insecure --console
Windows用 --console
,
mysqld -install
mysqld -install
执行 mysqld -install
必须要管理员权限 ! , 会生成mysql服务
net start mysql
net start mysql
net start mysql
启动MySQL服务
对应的
net stop mysql
net stop mysql
停止MySQL服务