Windows安装及配置MySQL

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值