时间:2021-04-29 10:55:45 | 栏目:Mysql | 点击:次
1.从官网下载mysql-5.7.21-windowx64.zip mysql下载页面
2.解压到合适的位置(E:\mysql) 这名字是我改过的
3.配置环境变量,将E:\mysql\bin 添加到PATH中
4.在mysql目录下(E:\mysql) 创建 my.ini文件,内容如下:
[mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] #设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=E:\mysql # 设置mysql数据库的数据的存放目录 datadir=E:\mysql\data # 允许最大连接数 max_connections=200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB "#"为注释
5.管理员身份运行cmd
切换目录 cd E:\mysql\bin
生成mysql服务(就是安装my.ini文件)
E:\mysql\bin> mysqld -install; Service successfully installed.
生成data目录 E:\mysql\bin> mysqld --initialize-insecure --user=mysql
;
这里生成失败的话看下面
E:\mysql\bin>cd ../ E:\mysql> mysqld --initialize-insecure --user=mysql ;
启动mysql服务
E:\mysql\bin> net start mysql;
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
6.登录数据库,修改密码(默认为空)
E:\mysql\bin> mysql -u root -p; Enter password: //这里直接回车 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.21 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> use mysql; Database changed mysql> set password for 'root'@'localhost'=password('新密码'); mysql> flush privileges;
退出测试是否成功
mysql> quit; E:\mysql\bin> mysql -u root -p; Enter password:
注释:
在mysql中一条语句结束加;号
开始mysql服务net start mysql;
停止mysql服务net stop mysql;
生成服务mysqld -install;
删除服务mysqld -remove;
登录数据库mysql -u root -p;
退出mysql> quit;
总结