windows 安装 mysql5.7
- 解压archive
- 在解压后的目录中以ansi编码格式创建ini ,内容如下:
[mysqld]
##skip-grant-tables=1
port = 3306
basedir=E:\\workspace\\tools\\mysql-5.7.35-winx64
datadir=E:\\workspace\\tools\\mysql-5.7.35-winx64\\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=utf8
- 配置操作系统环境变量
- 以管理员身份运行cmd
C:\WINDOWS\system32>cd E:\workspace\tools\mysql-5.7.35-winx64\bin
C:\WINDOWS\system32>E:
- 注册mysql服务
E:\workspace\tools\mysql-5.7.35-winx64\bin>mysqld –install
如果以前系统装过mysql服务,执行E:\workspace\tools\mysql-5.7.35-winx64\bin>sc delete mysql 删除
- 初始化data目录
E:\workspace\tools\mysql-5.7.35-winx64\bin>mysqld --initialize-insecure,如果不初始化启动时会报:
E:\workspace\tools\mysql-5.7.35-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务无法启动。
服务没有报告任何错误。
请键入 NET HELPMSG 3534 以获得更多的帮助。
- 启动mysql
E:\workspace\tools\mysql-5.7.35-winx64\bin>net start mysql
8.连接mysql
E:\workspace\tools\mysql-5.7.35-winx64\bin>mysql -u root
9.更改密码为Happy123,并刷新权限
UPDATE mysql.user SET authentication_string = PASSWORD('****'), password_expired = 'N' WHERE User = 'root' AND Host = 'localhost';
flush privileges;
- 然后将my.ini文件中刚才加的skip-grant-tables这一行删掉,保存后再重启MySQL服务
E:\workspace\tools\mysql-5.7.35-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
E:\workspace\tools\mysql-5.7.35-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
11.使用密码进入mysql
E:\workspace\tools\mysql-5.7.35-winx64\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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>
- 点赞
- 收藏
- 关注作者
评论(0)