MySQL_安装

参考链接:https://www.cnblogs.com/Lemon-ZYJ/p/11275012.html
系统:win10
步骤

  1. 下载对应版本: https://dev.mysql.com/downloads/mysql/
  2. 解压到目标安装目录,如:C:\mysql-8.0.21-winx64
  3. 在解压目录:C:\mysql-8.0.21-winx64下创建名为my.ini 的配置文件,并输入以下内容保存:
[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
 
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\\mysql-8.0.21-winx64
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\web\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
  1. 以管理员身份(否则会报错)打开 cmd 命令行工具,切换目录:cd C:\mysql-8.0.21-winx64\bin
  2. 初始化数据库:mysqld --initialize --console,执行完成后,会输出 root 用户的初始默认密码,复制保存这个密码
  3. 安装:
C:\mysql-8.0.21-winx64\bin>mysqld install
Service successfully installed.
  1. 启动:
C:\mysql-8.0.21-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
  1. 登录:
C:\mysql-8.0.21-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21

Copyright (c) 2000, 2020, 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>
  1. 退出:exit 或 quit
mysql> quit
Bye

C:\mysql-8.0.21-winx64\bin>

你可能感兴趣的:(SQL,sql,mysql,数据库)