mysql下载安装配置 5.7.26 / 5.7.X(免安装版)详细安装教程

2020/05 20 02:05

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

选择操作系统和版本,我是64位win10,点击 Download 后会跳到Oracle登录页面要求登录后才能下载

不想注册oracle帐户的,也可在直接在这里下载:https://download.csdn.net/download/antma/12439797

我这里下载的  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

mysql-5.7.26-winx64bin>mysqld --initialize-insecure

5、然后执行 mysqld -install

mysql-5.7.26-winx64bin>mysqld -install

提示 Service successfully installed ,即安装成功

6、启动服务

mysql-5.7.26-winx64bin>net start mysql

7、停止服务

mysql-5.7.20-winx64bin>net stop mysql

8、登录mysql

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

C:toolsmysql-5.7.26-winx64bin>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

--转载请注明: https://www.macs.vip/archives/40