前提条件:
在mysql官网下载,比如mysql-5.6.26-winx64.zip,解压mysql-5.6.26-winx64,尽量不要去其他网站下载。
1、win10下,win+x键选择“命令提示符(管理员)”。
(注意:一定要用管理员运行CMD进入DOS!mysql-5.7.22-winx64同样适用。记得提前修改my.ini文件中的一些属性。)
2、在环境变量PATH中添加:
;D:\Program\MySql\mysql-5.6.26-winx64\bin
3、进入到mysql-5.6.26-winx64的bin目录下
C:\WINDOWS\system32>d:
D:\>cd D:\Program\MySql\mysql-5.6.26-winx64
D:\Program\MySql\mysql-5.6.26-winx64>cd bin
4、输入服务安装命令
D:\Program\MySql\mysql-5.6.26-winx64\bin>mysqld install MySQL --defaults file="D:\Program\MySql\mysql-5.6.26-winx64\my-default.ini"
Service successfully installed.
(下载的压缩包里如果没有my-default.ini,那么可以手工创建)
my-default.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.
# basedir = .....这里的起始路径不要是software开头,可以默认的Progra
# datadir = .....这里的起始路径不要是software开头,可以默认的Program
# 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
#mysql6配置了
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5、启动MYSQL服务
D:\Program\MySql\mysql-5.6.26-winx64\bin>net start MySQL(这个名称是services.msc中的服务名称,跟安装命令install后面的名称要保持一致)
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
6、修改MYSQL密码
D:\Program\MySql\mysql-5.6.26-winx64\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use mysql;
Database changed
mysql> UPDATE user SET password=PASSWORD("root") WHERE user='root';
/
alter user 'root'@'localhost' identified by 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> QUIT
Bye
7、测试密码是否修改成功
D:\Program\MySql\mysql-5.6.26-winx64\bin>mysql -uroot -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
标题:windows下安装mysql(压缩包版而非msi安装版)mysql-XX-winx64
作者:yazong
地址:https://blog.llyweb.com/articles/2016/06/05/1578160527466.html