Windows安装及配置MySQL

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: Windows安装及配置MySQL 一、下载 MySQL下载地址:https://dev.mysql.com/downloads/mysql/ 二、配置 因为下载的为.zip格式,是不要安装的,解压完成进行配置就可以使用。

Windows安装及配置MySQL

一、下载

MySQL下载地址:https://dev.mysql.com/downloads/mysql/

二、配置

因为下载的为.zip格式,是不要安装的,解压完成进行配置就可以使用。

1、解压完,将文件夹改名为:MySQL Server 5.7.21,放在D:\Tools\MySQL路径下(可根据自身的需求存放);

2、配置环境变量

计算机右键-->属性-->高级系统设置-->高级(环境变量),在path后面追加;D:\Tools\MySQL\MySQL Server 5.7.21\bin (注意是追加,不是覆盖)

3、MySQL Server 5.7.21下新建data文件夹和my.ini。

配置my.ini,basedir和datadir修改为对应的地址,如下:

basedir = D:\Tools\MySQL\MySQL Server 5.7.21

datadir = D:\Tools\MySQL\MySQL Server 5.7.21\data

[html] view plain copy

  1. # For advice on how to change settings please see
  2. # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
  3. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
  4. # *** default location during install, and will be replaced if you
  5. # *** upgrade to a newer version of MySQL.
  6. [client]
  7. default-character-set = utf8mb4
  8. [mysql]
  9. default-character-set = utf8mb4
  10. [mysqld]
  11. character-set-client-handshake = FALSE
  12. character-set-server = utf8mb4
  13. collation-server = utf8mb4_unicode_ci
  14. init_connect='SET NAMES utf8mb4'
  15. # Remove leading # and set to the amount of RAM for the most important data
  16. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  17. innodb_buffer_pool_size = 128M
  18. # Remove leading # to turn on a very important data integrity option: logging
  19. # changes to the binary log between backups.
  20. # log_bin
  21. # These are commonly set, remove the # and set as required.
  22. basedir = D:\Tools\MySQL\MySQL Server 5.7.21
  23. datadir = D:\Tools\MySQL\MySQL Server 5.7.21\data
  24. port = 3306
  25. server_id = .....
  26. # Remove leading # to set options mainly useful for reporting servers.
  27. # The server defaults are faster for transactions and fast SELECTs.
  28. # Adjust sizes as needed, experiment to find the optimal values.
  29. join_buffer_size = 128M
  30. sort_buffer_size = 16M
  31. read_rnd_buffer_size = 16M
  32. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

4、安装

进入D:\Tools\MySQL\MySQL Server 5.7.21\bin文件夹,在地址栏出入cmd回车,输入mysqld -install(若不行试着以管理员身份运行)。

Service successfully installed. --提示安装成功

5、运行/停止服务

安装成功后就要启动服务了,继续在cmd中输入:net start mysql(如图),服务启动成功!

继续在cmd中输入:net stop mysql(如图),服务停止成功!

6、进入MySQL

输入mysql -u root -p(第一次登录没有密码,直接按回车过),登录成功! --网上查了好多教程是这样的,然鹅,我居然失败了

解决办法:

(1)my.ini文件,在里面找到 [mysqld] 这一项,然后在该配置项下添加 skip-grant-tables这个配置,然后保存文件。

(2)重启mysql服务。net stop mysql / net start mysql

(3)输入mysql -u root -p,回车,果然登录成功!哈哈~

(4)修改密码

在mysql5.7以下的版本如下:
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='127.0.0.1' or host='localhost';//把空的用户密码都修改成非空的密码就行了。

在mysql5.7版本如下:

update mysql.user set authentication_string=password('newpassword') where user='root' and host='127.0.0.1' or host='localhost';

mysql> FLUSH PRIVILEGES;
mysql> quit # /etc/init.d/mysqld restart //离开并重启mysql
# mysql -uroot -p

Enter password: <输入新设的密码newpassword>

原文地址http://www.bieryun.com/3473.html

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
8天前
|
关系型数据库 MySQL 数据库
mysql卸载、下载、安装(window版本)
mysql卸载、下载、安装(window版本)
|
14天前
|
安全 Windows
安装MyEclipse遇到错误提示 Failed to find a Main Class in “C:Windows\Temp\“时的解决方案
安装MyEclipse遇到错误提示 Failed to find a Main Class in “C:Windows\Temp\“时的解决方案
21 1
|
7天前
|
SQL 缓存 关系型数据库
mysql性能优化-慢查询分析、优化索引和配置
mysql性能优化-慢查询分析、优化索引和配置
66 0
|
13天前
|
缓存 关系型数据库 MySQL
MySQL查询优化:提速查询效率的13大秘籍(合理使用索引合并、优化配置参数、使用分区优化性能、避免不必要的排序和group by操作)(下)
MySQL查询优化:提速查询效率的13大秘籍(合理使用索引合并、优化配置参数、使用分区优化性能、避免不必要的排序和group by操作)(下)
|
21天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 中apt 安装MySQL数据库
Ubuntu 中apt 安装MySQL数据库
65 0
|
4天前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL 安装及连接
MySQL 安装及连接
22 0
|
7天前
|
关系型数据库 MySQL 数据库
docker自定义安装mysql 5.7
docker自定义安装mysql 5.7
15 0
|
7天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
32 0
|
7天前
|
关系型数据库 MySQL Linux
win安装mysql5.7 和安装出现的问题
win安装mysql5.7 和安装出现的问题
9 0
|
22天前
Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
14 1

推荐镜像

更多