4

MySQL下载安装教程

 2 years ago
source link: https://segmentfault.com/a/1190000040854029
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

MySQL的下载与安装

一、MySQL下载

MySQL下载地址:https://dev.mysql.com/downloa...
image.png

选择windows版本和点击下载第一个版本(非debug test版本),这是一个zip文件压缩文件

2、MySQL安装

  • 解压zip包到安装目录
    我的解压目录是:C:\Program Files\MySQL\mysql-8.0.27-winx64
  • 配置文件
    在安装根目录下添加 my.ini文件,我的目录是:C:\Program Files\MySQL\mysql-8.0.27-winx64\my.ini

    [mysqld]
    # 设置3306端口
    port=3306
    # 设置mysql的安装目录
    basedir=C:\Program Files\MySQL\mysql-8.0.27-winx64
    # 设置mysql数据库的数据的存放目录
    datadir=C:\Program Files\MySQL\mysql-8.0.27-winx64\Data
    # 允许最大连接数
    max_connections=200
    # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
    max_connect_errors=10
    # 服务端使用的字符集默认为UTF8
    character-set-server=utf8
    # 创建新表时将使用的默认存储引擎
    default-storage-engine=INNODB
    # 默认使用“mysql_native_password”插件认证
    default_authentication_plugin=mysql_native_password
    [mysql]
    # 设置mysql客户端默认字符集
    default-character-set=utf8
    [client]
    # 设置mysql客户端连接服务端时默认使用的端口
    port=3306
    default-character-set=utf8

    然后把内容里面的 mysql的安装目录数据的存放目录 换成自己的

  • 初始化仓库
    在MySQL安装目录的 bin 目录下执行命令:

    mysqld --initialize --console

    执行完之后,会给出默认密码(下图中红框圈的即为默认密码),一定要记下,方便后续修改密码
    image.png

  • 安装并启动服务
    在MySQL安装目录的 bin 目录下执行命令(以管理员身份打开cmd)

    mysqld --install    //安装服务
    net start mysql     //启动服务

    image.png

3、MySQL修改密码

在MySQL安装目录的 bin 目录下执行命令:

mysql -u root -p

然后输入数据库密码进入,执行命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';

image.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK