window下MySQL5.7.zip服务配置

来源:互联网 发布:导入支付宝数据账本 编辑:程序博客网 时间:2024/05/22 15:47

官网下载了压缩包版本的mysql-5.7.13-winx64.zip,解压。

再解压目录下新建一个my.ini文件,内容如下:

# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[mysql]# 设置mysql客户端默认字符集default-character-set=utf8[mysqld]# 忽略登录检查(<span style="font-family: Arial, Helvetica, sans-serif;">忽略</span><span style="font-family: Arial, Helvetica, sans-serif;">登陆检查)</span>skip_grant_tables# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.# basedir=D:\\software\\mysql\\mysql-5.7.13-winx64# datadir=D:\\software\\mysql\\mysql-5.7.13-winx64\\dataport = 3306# server_id = .....# 允许最大连接数max_connections=200character-set-server=utf8# 创建新表时将使用的默认存储引擎default-storage-engine=INNODB# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M # sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 


skip_grant_tables 忽略登录检查;mysql5.7增加了安全性,初始密码不再为空。


以管理员身份运行cmd, 打开到文件解压的目录中的bin下运行下面的指令创建并且启动服务(可以在环境变量设置为全局指令):

D:\software\mysql\mysql-5.7.13-winx64\bin>mysqld --initializeD:\software\mysql\mysql-5.7.13-winx64\bin>mysqld --installService successfully installed.D:\software\mysql\mysql-5.7.13-winx64\bin> net start mysqlMySQL 服务正在启动 .MySQL 服务已经启动成功。D:\software\mysql\mysql-5.7.13-winx64\bin>mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.13 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>


mysqld --initialize 初始化目录(data目录),如果执行命令失败,需先删除data目录后再执行;

mysqld -install 初始化mysql服务;


net start mysql 启动服务;

net stop mysql 停止服务。


修改密码:

</pre><pre name="code" class="plain">mysql> use mysql;Database changedmysql> update user set authentication_string=password('123456') where user='root';Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 1  Changed: 0  Warnings: 1mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)

mysql5.7的user中没有password字段,保存密码的字段变成authentication_string


关闭mysql服务,删掉my.ini中的skip_grant_tables;

重新启动服务,输入密码就可以登陆。


出现下面这个:

You must reset your password using ALTER USER statement before executing this statement.

解决:

step 1: SET PASSWORD = PASSWORD('root'); 
step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
step 3: flush privileges;





0 0