mysql免安装版配置教程

1. 下载MySQL免安装版压缩包

2. 解压MySQL压缩包,将以下载的MySQL压缩包解压到自定义目录下,我的解压目录是:"D:\dev\tools",复制下面的配置信息到 my-default.ini 保存。(注意更改basedir和datadir两个参数的值)

# 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:\dev\tools\mysql
# datadir = D:\dev\tools\mysql\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 


3. 添加环境变量
    操作如下:
    1)右键单击我的电脑->属性->高级系统设置(高级)->环境变量,点击系统变量下的新建按钮
      输入变量名:MYSQL_HOME
      输入变量值:D:\dev\tools\mysql
      #即为mysql的自定义解压目录。
    2)选择系统变量中的Path,点击编辑按钮,在变量值中添加变量值:%MYSQL_HOME%\bin
      注意是在原有变量值后面加上这个变量,用;隔开,不能删除原来的变量值,


4. 将mysql注册为windows系统服务

  1)以管理员身份进入控制台,从控制台进入到MySQL解压目录下的 bin 目录下:

    2)输入服务安装命令:
输入: mysqld -install

安装成功后就要启动服务了,启动服务命令为:  net start mysql  ;移除服务命令为:mysqld remove

5. 启动MySQL服务
    方法一:
        启动服务命令为:net start mysql
    方法二:
        打开管理工具 服务,找到MySQL服务,通过右键选择启动或者直接点击左边的启动来启动服务。


6. 修改 root 账号的密码

    刚安装完成时root账号默认密码为空(需注意:假如你重装了系统,但还是使用你之前的mysql文件夹,则密码是你之前设置过的密码),此时可以将密码修改为指定的密码。如:123456
    c:>mysql –uroot 或 mysql -u root -p
    mysql>show databases;
    mysql>use mysql;
    mysql>update user set password=("123456") where user='root';
    mysql>flush privileges;
    mysql>quit
 
7. MySQL控制台快捷方式建立:
    1)桌面右键->新建->快捷方式->对象位置输入:C:\Windows\System32\cmd.exe
        快捷方式名称自己定义,确定,快捷方式建立成功
    2)右键单击刚才建立的快捷方式->属性->把目标一栏修改成MySQL启动参数:
        C:\Windows\System32\cmd.exe "D:\dev\tools\mysql\bin" /k mysql -uroot -p inventory
        解释:CMD路径 "MySQL路径bin目录" /k mysql -u用户名 -p密码 数据库名
    3)修改完成后点击确定保存,直接双击快捷方式即可连接到MySQL数据库

猜你喜欢

转载自blog.csdn.net/brianwey/article/details/79264028