mysql-5.7.18-winx64 免安装版配置

  如题,最新的都是只有免安装版的,可以官网下载zip的压缩包。

  下载后解压,如下

下面就开始配置

1、在path中添加环境变量

  ;D:codingmysql-5.7.18-winx64in;  ← 根据自己的实际解压后文件夹的路径(注意跟前面的配置用;隔开)

2、配置ini文件

  可以看到最新版的解压后根目录没有xxx.ini的配置文件。我们可以从别的地方拷贝一个,

  或者点此下载链接:http://pan.baidu.com/s/1pL6uxuF 密码:m2r7

  也可以自己新建一个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.

[mysqld]

# 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:codingmysql-5.7.18-winx64
 datadir = D:codingmysql-5.7.18-winx64data
 port = 3306
 max_connections=20
 character_set_server=utf8
# server_id = .....


# 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 

explicit_defaults_for_timestamp=true
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
[WinMySQLAdmin]
D:codingmysql-5.7.18-winx64inmysqld.exe
View Code

 

3、初期化

  进入cmd中运行如下命令,这个命令会初期化我们刚刚配置的一个data文件夹(运行前,这个data文件夹是不存在的)

  mysqld  --initialize

  运行后,出现了data文件夹,并且里面已经有一些文件了

4、安装服务

  运行如下命令来安装服务

  mysqld install 

 

 5、提示安装完成后,就可以启动服务了。

运行如下命令,当然,也可以自己在服务中手动启动mysql服务。

 net start mysql

 6、下面就可以去连接mysql了,但是这时候root的用户密码我们还不知道,所以需要先去修改一下root用户的密码。

  ①关闭mysql服务,命令: net stop mysql   当然也可以手动关闭

  ②启动mysql的安全模式,命令:mysqld --skip-grant-tables

  运行效果如下,光标一直在闪,我们不用管,打开一个新的cmd窗口。

  ③在新打开的cmd窗口,登陆root用户,命令:mysql -uroot -p

  提示输入密码,直接回车,就可以登陆了。

  

  ④接下来就是修改root用户的密码了。运行如下的命令。

    use mysqll;

    update user set authentication_string=password("root") where user="root";

  红色字体部分就是修改后的密码了。

   ⑤接下来运行刷新命令,就大功告成了,就可以去正常的登陆了。

    flush privileges;

 7、正常登陆效果

  

原文地址:https://www.cnblogs.com/zerotomax/p/7184113.html