Window版本html
卸载本来的mysqlpython
sc delete MySQL //删除mysqlmysql
一、下载sql
1
2
3
|
MySQL
https://dev.mysql.com/downloads/installer/
|
二、解压数据库
三、初始化windows
MySQL解压后的 bin 目录下有一大堆的可执行文件,执行以下命令初始化数据:服务器
1
2
3
|
终端运行
c:\mysql - 5.7 . 16 - winx64\ bin>>
mysqld - - initialize - insecure
|
四、启动MySQL服务ui
执行命令从而启动MySQL服务编码
1
2
3
4
5
|
# 启动MySQL服务
|
五、启动MySQL客户端并链接MySQL服务spa
因为初始化时使用的【mysqld --initialize-insecure】命令,其默认未给root帐户设置密码
1
2
3
4
5
6
7
|
# 进入可执行文件目录
cd c:\mysql - 5.7 . 16 - winx64\ bin>>
# 链接MySQL服务器
mysql - u root - p
# 提示请输入密码,直接回车
|
MySQL服务端已经安装成功而且客户端已经能够链接上,之后再操做MySQL时,只须要重复上述四、5步骤便可。
自主修改端口号:
复制下面代码在文件根目录下建立 my.ini 文件
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/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. # 当前版本 5.7.20 [mysql] #设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] # 跳过密码,直接进入 # skip-grant-tables # 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 max_allowed_packet=40M # 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 =G:\mysql5.7\mysql-5.7.23-winx64\mysql-5.7.23-winx64 #设置mysql数据库的数据的存放目录 datadir = G:\mysql5.7\mysql-5.7.23-winx64\mysql-5.7.23-winx64\data #设置端口 port = 3308 # server_id = ..... #容许最大链接数 max_connections=200 #服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 建立新表时将使用的默认存储引擎 default-storage-engine=INNODB # 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 character-set-server=utf8 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
设置密码:
mysqladmin -u root -p password 密码。
快捷:
a. 添加环境变量
将MySQL可执行文件添加到环境变量中,从而执行执行命令便可
1234【右键计算机】
-
-
》【属性】
-
-
》【高级系统设置】
-
-
》【高级】
-
-
》【环境变量】
-
-
》【在第二个内容框中找到 变量名为Path 的一行,双击】
-
-
> 【将MySQL的
bin
目录路径追加到变值值中,用 ; 分割】
如:
C:\Program Files (x86)\Parallels\Parallels Tools\Applications;
%
SystemRoot
%
\system32;
%
SystemRoot
%
;
%
SystemRoot
%
\System32\Wbem;
%
SYSTEMROOT
%
\System32\WindowsPowerShell\v1.
0
\;C:\Python27;C:\Python35;C:\mysql
-
5.7
.
16
-
winx64\
bin
如此一来,之后再启动服务并链接时,仅需:
12345# 启动MySQL服务,在终端输入
mysqld
# 链接MySQL服务,在终端输入:
mysql
-
u root
-
p
b. 将MySQL服务制做成windows服务
上一步解决了一些问题,但不够完全,由于在执行【mysqd】启动MySQL服务器时,当前终端会被hang住,那么作一下设置便可解决此问题:
12345# 制做MySQL的Windows服务,在终端执行此命令:
(需在
C:\mysql
-
5.7
.
16
-
winx64\
bin
下)>>mysqld
-
-
install
# 移除MySQL的Windows服务,在终端执行此命令:(需在
C:\mysql
-
5.7
.
16
-
winx64\
bin
下)>>mysqld
-
-
remove
注册成服务以后,之后再启动和关闭MySQL服务时,仅需执行以下命令:
12345# 启动MySQL服务
net start mysql
# 关闭MySQL服务
net stop mysql