此教程提供mysql服务安装教学,拒绝捆绑软件并且还是默认安装在c盘下的 mysql installer
mysql msi版本下载地址:https://mirrors.aliyun.com/mysql/
安装
-
官网下载mysql,下载完后解压
-
配置环境变量Path(此步不做)
Path=D:\Programs\mysql-8.0.33-winx64\bin
- 以管理员身份运行cmd,来到MySQL的bin目录下,运行下列命令
此处会生成默认密码,复制这个密码,修改密码时要用到
不用管理员也可
mysqld --initialize --console
管理员:
mysqld --install
启动mysql服务:
net start mysql
修改密码
- 登录mysql
mysql -u root -p
- 修改密码,123456为新密码
ALTER user 'root'@'localhost' IDENTIFIED BY '123456'
- 使用修改后的密码登录
mysql -u root -p
登陆成功
此方法也适用于msi版本的安装,msi版本可以在搜狐镜像站找到:https://mirrors.sohu.com/mysql/
阿里云镜像:https://mirrors.aliyun.com/mysql/
问题:mysql 8.0在安装后找不到my.ini,%programdata%里都没有mysql/mysql 8.0的文件夹
mysql 5.7 安装后在%programdata%里有mysql/mysql 5.7这个文件夹,但是里面没有my.ini
删除服务:sc delete 服务名
mysql安装指定服务名以及mysql的配置文件
mysql5.7安装
Microsoft Windows [版本 10.0.19045.3570]
(c) Microsoft Corporation。保留所有权利。
C:\Windows\system32>mysqld --initialize --console
2023-11-14T08:46:24.148356Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-11-14T08:46:24.358445Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-11-14T08:46:24.392164Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-11-14T08:46:24.471087Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4ac748c7-82ca-11ee-ae44-000c296dd905.
2023-11-14T08:46:24.474917Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-11-14T08:46:25.227271Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-11-14T08:46:25.227902Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-11-14T08:46:25.228976Z 0 [Warning] CA certificate ca.pem is self signed.
2023-11-14T08:46:26.016500Z 1 [Note] A temporary password is generated for root@localhost: uvmL7V2AXU.G
C:\Windows\system32>mysqld --install
Service successfully installed.
C:\Windows\system32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
C:\Windows\system32>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.38
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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>
如果密码错误就把mysql卸载干净,再重新来一遍
sc delete mysql
或
mysqld --remove 服务名
怎么进入D盘