Loading

Mysql安装教程

这里使用压缩包的方式安装Mysql

下载Mysql压缩包文件

https://dev.mysql.com/downloads/mysql/

解压到磁盘目录

配置环境变量

新建Mysql配置文件

[mysqld]
basedir=D:\mysql-8.0.22\
datadir=D:\mysql-8.0.22\data
port=3306
skip-grant-tables

管理员方式启动cmd,进入到Mysql目录的bin目录下

cd /d D:\mysql-8.0.22\bin

安装Mysql服务

mysqld -install

Tips:关闭服务的命令为:net stop mysql, 卸载的命令为:sc delete mysql。

初始化数据库文件

mysqld --initialize-insecure --user==mysql

启动mysql

net start mysql

修改密码

MySQL 5.7 的版本,因为在user表中没有password字段,一直使用下边的方式来修改root密码

use mysql; 
update user set authentication_string = password(“123456”) where user = “root”;

MySql 从8.0开始修改密码有了变化,在user表加了字段authentication_string,修改密码前先检查authentication_string是否为空

  1. 如果不为空
use mysql; 
 
update user set authentication_string='' where user='root';--将字段置为空
 
ALTER user 'root'@'localhost' IDENTIFIED BY '123456';--修改密码为123456
  1. 如果为空,直接修改
ALTER user 'root'@'localhost' IDENTIFIED BY '123456';--修改密码为123456

如果出现如下错误

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY '123' WITH GRANT OPTION;

需要执行

flush privileges;

然后再执行

ALTER user 'root'@'localhost' IDENTIFIED BY '123456';--修改密码为123456
posted @ 2020-11-18 11:49  傲慢与偏见luc  阅读(93)  评论(0编辑  收藏  举报