1、数据库下载
从Mysql官方网站:http://www.mysql.com/ 下载,推荐下载ZIP版,只需要解压,比较方便。这里下载的是目前最新版的64位MySql,mysql-5.6.25-winx64.zip。
2、修改配置文件
解压下载下来的压缩包到常用目录,如D:\TOOLS\mysql-5.6.25-winx64,打开文件夹复制一份my-default.ini配置文件,命名为my.ini。
my-default.ini不要动它,打开my.ini配置文件,加入如下语句:
basedir = D:\TOOLS\mysql-5.6.25-winx64
datadir = D:\TOOLS\mysql-5.6.25-winx64\data
[WinMySQLadmin]
Server = D:\TOOLS\mysql-5.6.25-winx64\bin\mysqld.exe
修改完的配置文件如下:
# 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:\TOOLS\mysql-5.6.25-winx64
datadir = D:\TOOLS\mysql-5.6.25-winx64\data
# port = .....
# 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
[WinMySQLadmin]
Server = D:\TOOLS\mysql-5.6.25-winx64\bin\mysqld.exe
这些设置为了保证服务正常运行,可以根据自己需要调整参数,修改后要重启服务才能生效。
3、注册服务
Mysql服务需要注册才能使用,打开cmd,然后cd到mysql安装目录的bin下面,如“D:\TOOLS\mysql-5.6.25-winx64\bin”,然后执行 mysqld -install,提示“Service successfully installed.”。(如果出现报错:Install/Remove of the Service Denied,则运行cmd的时候使用管理员身份即可。)运行services.msc,可以看到一个名为MySQL的服务了。如果想要删除MySql服务,执行mysqld -remove。
4、启动服务
运行services.msc,启动MySql服务。
5、登陆MySql
刚才已经安装完了,现在我们登陆一下。
MySQL的默认用户名是root,密码为空。
cd到bin目录下,执行“mysql -u root -p”,提示输入密码,密码为空可以直接回车。这样就登陆完成。