win10系统如何安装MySQL

win10系统如何安装MySQL

我发现Windows系统安装mysql过程中,即使用的同样的安装包、同样的安装步骤,也可能遇到不同的问题。本文提供个人安装成功的经验,供大家参考。

1、下载对应版本。

  https://dev.mysql.com/downloads/mysql/

  (不少人建议下载5.5或者5.6版本,企业用的比较多。)

2、配置my.ini文件。

  这里我提供两种方法,第一种是别人成功了,第二种是我安装成功的例子。

  第一种方法。将以下代码复制到一个my.ini的文件中,将文件保存在MySQL的安装目录下即可。

[mysql]
default-character-set=utf8
[mysqld]
port = 3306
basedir=D:\MySQL\MySQL Server 5.7.22
datadir=D:\MySQL\MySQL Server 5.7.22\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB

我用这种方法时,出现了1067错误,然后用第二种方法解决了。

第二种方法。不用自己设置my.ini文件,直接在原有的my-default.ini文件中修改成下面的样子。

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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:\MySQL\MySQL Server 5.7.22
datadir = D:\MySQL\MySQL Server 5.7.22\data
port = 3306
# 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 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
View Code

3、配置环境变量---将安装目录配置到环境变量下的path中。

  在桌面右击“我的电脑”→属性→高级系统设置→环境变量→在下方的“系统变量”中,双击path→新建→将MySQL的安装地址复制粘贴即可。

4、以administrator运行cmd,cd到MySQL安装目录的bin目录下。

5、输入mysqld install,安装程序。

6、接着启动MySQL服务端,输入net start mysql(如果要重启,需要先net stop mysql停止程序)。

      也可以在任务管理器的“服务”项目中启动。

7、最后启动用户端,输入mysql,如果不报错,就是启动成功了。

猜你喜欢

转载自www.cnblogs.com/hellowgh/p/12203370.html