mysql5.7.13-windows 免安装版配置简介

1.下载mysql5.7.13-windows版本

     (1)mysql5.7.13-win64版本百度云下载链接分享地址:链接:http://pan.baidu.com/s/1slMl4Ah 密码:w60l

    (2)mysql5.7.13-win32版本百度云下载链接分享地址:链接:http://pan.baidu.com/s/1c2kcwFI 密码:qk3n

2.解压下载的mysql文件到自己电脑的指定路径

     在这里我解压的路径如下图一:

图一:我的mysql下载文件解压路径

3.配置mysql环境变量

  (1)右键单击我的电脑->属性->高级系统设置(高级)->环境变量
      点击系统变量下的新建按钮
      输入变量名:MYSQL_HOME
      输入变量值:F:\mysql
      #即为mysql的自定义解压目录,具体如下图二所示:

图二:为mysql配置环境变量


 
(2)选择系统变量中的Path
      点击编辑按钮
      在变量值中添加变量值:%MYSQL_HOME%\bin
      注意是在原有变量值后面加上这个变量,用;隔开,不能删除原来的变量值。具体如下图三所示(PS:我目前计算机是WIN10系统,直接填写%MYSQL_HOME%\bin即可)

图三:mysql环境变量配置

4.在解压后的mysql文件中添加一个my.ini文件

   在F:\mysql路径下,新建一个txt文本,然后修改扩展名,并命名为my.ini,在该文件中放入以下代码(PS:经过下面的设置后,随后建立数据库时不会出现中文乱码和中文无法插入的问题哟):

####################配置文件开始###################

 # 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.

 [client]

 default-character-set=utf8

 

 [mysqld]

 character-set-server=utf8 port=
3306 basedir ="F:\mysql/" datadir ="F:\mysql/data/" tmpdir ="F:\mysql/data/" socket ="F:\mysql/data/mysql.sock" log-error="F:\mysql/data/mysql_error.log" #server_id = 2 #skip-locking max_connections=100 table_open_cache=256 query_cache_size=1M tmp_table_size=32M thread_cache_size=8 innodb_data_home_dir="F:\mysql/data/" innodb_flush_log_at_trx_commit =1 innodb_log_buffer_size=128M innodb_buffer_pool_size=128M innodb_log_file_size=10M innodb_thread_concurrency=16 innodb-autoextend-increment=1000 join_buffer_size = 128M sort_buffer_size = 32M read_rnd_buffer_size = 32M max_allowed_packet = 32M explicit_defaults_for_timestamp=true sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES ####################配置文件结束###################

    其中有关路径的地址均填写自己解压mysql文件的实际存放地址

 

5.安装mysql服务和登录mysql

      首先,以管理员身份打开cmd,接下来进行以下步骤:

    (1)使用命令:mysqld --initialize-insecure,这个命令会生成无密码的root用户。而命令mysqld --initialize自动生成带随机密码的root用户。这里建议使用mysqld --initialize-insecure命令生成无密码的root用户。

提示:使用mysqld --initialize-insecure命令后结果:因为解压后的mysql文件夹中没有data文件夹,此处进行该命令后便会自动生成data文件夹

    (2)紧接着,使用命令:mysqld --install ,安装mysql服务(PS:mysql remove为卸载mysql服务)

    (3)启动mysql服务使用命令:net start mysql,开启mysql服务

    (4)使用命令:首先输入mysql -u root -p,enter键进入到mysql,再次enter键进入(注意此处是不需要输入密码的)

 

如果在第一步中使用mysqld --initialize-insecure命令,安装成功后,mysql的root账户密码为空,现在可以按照如下所示,进行修改密码:

操作步骤:

use mysql;

update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';


FLUSH PRIVILEGES;

 

具体演示结果:

修改密码

密码修改成功后,在cmd中重新登陆

 

C:\Users\Administrator>mysqld --initialize-insecure

C:\Users\Administrator>mysqld --install
Service successfully installed.

C:\Users\Administrator>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。


C:\Users\Administrator>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.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 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> use mysql;
Database changed
mysql> update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

 

 一款mysqlIDE下载推荐:链接:https://pan.baidu.com/s/152dLe2b9I6rmeJCmDIOeMg 密码:168a

 

 


附:进行到步骤(3)时,无法启动服务,可能会出现以下错误:

错误1:mysql服务启动发现系统错误2

解决方法:

(1)

(2)

 

 

错误2:mysql服务启动发现系统错误193

解决办法:

 

也有可能是如下:

错误3:mysql服务启动发现系统错误3

解决办法:

 

错误4:mysql服务启动 系统没有报告任何错误

解决办法:

 

错误5:mysql服务无法启动,有可能是3306端口被占

解决办法:

打开cmd,输入netstat -ano,查看端口使用情况

 

posted @ 2016-07-20 12:03  舞动的心  阅读(3968)  评论(0编辑  收藏  举报