Home  >  Article  >  Database  >  MySQL绿色版(zip解压版)的安装图文教程(mysql-5.6.22-win32.zip)_MySQL

MySQL绿色版(zip解压版)的安装图文教程(mysql-5.6.22-win32.zip)_MySQL

WBOY
WBOYOriginal
2016-07-06 13:32:461092browse

1、数据库下载

  Mysql官方网站:http://www.mysql.com/,数据库下载地址:http://www.mysql.com/downloads/。从官方网站可以找到两种文件包,一种是exe安装程序,另一种是zip压缩包。本人喜欢清爽的方式,所以下载的是ZIP压缩包。最新的5.6.22大概350M,下载还需要oracle帐号,自己注册一个好了。
 

2、数据库安装

  解压出下载的文件mysql-5.6.22-win32.zip(有x86和x64两个版本)到任一目录,防止出现未知问题,最好放在非系统盘的非中文目录下,我的位置C:\Program Files\mysql-5.6.22-win32。打开文件夹复制一份my-default.ini为my.ini的配置文件。

    

  打开my.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.
#mysql根目录
 basedir ="C:\Program Files\mysql-5.6.22-win32"
#数据文件存放目录
 datadir ="C:\Program Files\mysql-5.6.22-win32\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 
#服务端的编码方式
character-set-server=utf8
[client]
#客户端编码方式,最好和服务端保存一致
loose-default-character-set = utf8

[WinMySQLadmin] 
Server = "C:\Program Files\mysql-5.6.22-win32\bin\mysqld.exe"

如果需要更优化的my.ini配置文件可以参考这篇文章:http://www.bitsCN.com/article/84357.htm

上面设置为了保证服务正常运行,根据自己需要调整参数,修改后要重启服务。

3、注册Mysql服务

  开始——运行——cmd,然后cd到mysql安装目录的bin下面,我的目录就是“C:\Program Files\mysql-5.6.22-win32\bin”,然后执行mysqld -install,提示服务安装成功!运行services.msc一看,确实有一个名为MySQL的服务了,启动它。有时启动失败,根据情况调整参数即可。
  到这儿mysql安装就算完成了,其实还挺简单的,但如果没有操作过,整个过程估计要花不少时间,也是成长必须的过程。

4、登录维护Mysql

  安装成功了,也启动了,怎么登录啊?用户名和密码是什么 ?

  MySQL的默认用户名是root,密码为空。

  怎么登录?还是开始——运行——cmd,cd到bin目录下,然后执行“mysql -u root -p”,提示输入密码,由于第一次运行,密码为空可以直接回车。

   

  还是给数据库设个密码吧。输入exit退出登录。然后运行运行C:\Program Files\mysql-5.6.22-win32\bin\mysqladmin -uroot -p password ,将替换为你的自定义密码,然后按回车。这时会提示输入密码,其实是指的原密码,原密码因为是空,所以这里再回车即可完成设置。然后用上面的方法和新密码登入mysql,即可正常工作。

  运行"show variables like '%version%'" 查看数据库相关信息

  

  至此,整个数据库的安装完成。

  虽然mysql客户端能完成所有关于数据库操作,但是黑黑的命令行界面还是让很多人望而却步,学习曲线直线上升,在此给大家推荐一个工具Navicate for mysql,个人感觉非常好用,各种操作一目了然,还有个SQLyog也不错。

  

 

5、开启远程登录

    mysql安装完成后默认只能本机(就是localhost)登录, 我们需要开启远程登录才方便使用. 开启方法有很多,百度一大把, 我说一下测试通过的方法

x:\>mysql -u root -p 密码  //登录系统
mysql> use mysql;    //切换数据库
mysql> update user set host = '%' where user = 'root'; 
//上面这句话有时出现一个错误 ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'

//不过这时你查询一下user表发现已经更新一条记录了,下面这句话
mysql> select host, user from user;

//直接执行这句,其实就是刷新权限
mysql> flush privileges;

再测试远程连接试试, 已经可以了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn