下载:MySQL :: Download MySQL Community Server
安装步骤:
1、切换到mysql/bin目录
2、删除之前的安装
mysqld --remove mysql
3、初始化(注意保存密码)
mysqld --initialize --user=root --console
4、安装
mysqld --install
5、启动
mysqld
6、登录
mysql -u root -p
7、修改密码规则、修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
--------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
F:\soft\mysql-8.0.32-winx64\bin>mysqld --remove mysql
Install/Remove of the Service Denied!
F:\soft\mysql-8.0.32-winx64\bin>mysqld --initialize --user=root --console
2023-03-19T08:25:51.239516Z 0 [System] [MY-013169] [Server] F:\soft\mysql-8.0.32-winx64\bin\mysqld.exe (mysqld 8.0.32) initializing of server in progress as process 8452
2023-03-19T08:25:51.267504Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-03-19T08:25:51.749616Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-03-19T08:25:53.121640Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fwYhs_:Tj1LO
F:\soft\mysql-8.0.32-winx64\bin>mysqld --install
Install/Remove of the Service Denied!
常见SQL问题:
1、修改查询模式(3065)
SELECT VERSION();
SELECT @@GLOBAL.sql_mode;
SELECT @@sql_mode;
SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
SET @@GLOBAL.sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
2、修改用户访问权限
update user set host='%' where user='root';
flush privileges;
3、修改密码规则和密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
4、跳过授权登录
-- 跳过授权表进行免密登录
mysqld --console --skip-grant-tables --shared-memory
5、在windows server 2012安装参考