WIN7系统安装MySQL5.6

2022-11-21 18:54:40 浏览数 (1)

Win7下安装Mysql方法

下载mysql安装包

MySQL官网

进行配置

安装包名称:mysql-5.6.12-winx64.zip 解压安装包,记路径,我就直接放在桌面了,并且做了重命名 C:UsershyDesktopmysql 修改mysql目录下的配置文件my.ini如下:

代码语言:javascript复制
# 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.

[client]
default-character-set=utf8

[mysql]

default-character-set=utf8

[mysqld]
character-set-server=utf8
# 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 = C:UsershyDesktopmysql
 datadir = C:UsershyDesktopmysqldata
# 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

安装mysql

以管理员身份启动cmd,切换到目录C:UsershyDesktopmysqlbin 安装mysql:mysqld.exe --install(CMD中执行后,如果报拒绝,则需要用管理员权限运行CMD,然后执行该命令) 往往都是权限不够导致的

以管理员身份运行的方式:找到运行程序cmd.exe,右键以管理员方式运行 C:WindowsSystem32

启动MySQL

以管理员身份启动cmd,切换到目录D:/mysql-5.6.12-win32/bin

代码语言:javascript复制
  启动mysql服务:net start MySQL

(若想在cmd命令中直接运行指令,而不用进入bin目录下,需要在环境变量中增加路径,如图:

PS:系统默认的Mysql是自启动的,修改为手工启动的方法:

进入本机的“服务”,修改为手动启动即可,如图:

执行命令

登录mysql

代码语言:javascript复制
  mysql -u root -p

  输入密码(密码为空,直接回车),即可登录。
  修改root密码为123456:
代码语言:javascript复制
mysql > set password = password('123.com');
mysql > flush privileges;
mysql > exit

停止mysql服务

代码语言:javascript复制
net stop MySQL

卸载mysql服务

代码语言:javascript复制
mysqld.exe --remove

0 人点赞