1、下载mysql,下载地址:https://downloads.mysql.com/archives/community/

选择操作系统和版本,我是64位win10,点击 Download 下载ZIP Archive版本,我这里下载的  5.7.26 ,基它 5.7.X 的安装都是类似的,没什么区别。

2、下载完成后解压:

 

3、在mysql目录下手工创建 my.ini 文件,如上图,文件内容如下,basedir 和 datadir 修改为相应地址:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[mysqld]
#设置3306端口
port = 3308
# 设置mysql的安装目录
basedir=C:/tools/mysql-5.7.26-winx64
# 设置mysql数据库的数据的存放目录
datadir=C:/tools/mysql-5.7.26-winx64/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

4、以管理员身份打开cmd,进入bin目录下,执行 mysqld --initialize-insecure

 

c:\mysql-5.7.26-winx64\bin>mysqld --initialize-insecure

5、然后执行 mysqld -install

复制复制复制复制复制复制

复制

c:\mysql-5.7.26-winx64\bin>mysqld -install

提示 Service successfully installed ,即安装成功

6、启动服务

复制复制复制复制复制

复制

c:\mysql-5.7.26-winx64\bin>net start mysql

7、停止服务

 

c:\mysql-5.7.20-winx64\bin>net stop mysql

8、登录mysql

因为上面初始化参数使用的 --initialize-insecure,所以登录为空密码,直接  mysql -uroot -P3308 即可直接登录:

 

C\:tools\mysql-5.7.26-winx64\bin>mysql -uroot -P3308
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>

9、修改mysql 密码:

 

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');

完成!

注:如果出现安装mysql Install/Remove of the Service Denied! 报错的时候,在打开 cmd 时用管理员身份打开。

或如下提示也是需管理员身份:Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off

 

该资源来源于WordPress主站,点击下方按钮前往原文页面获取完整内容:

跳转至 WordPress 主站原文页面

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。