一、MySQL数据库下载
1.进入MySQL数据库官网
官网地址:https://www.mysql.com/
2.点击DOWNLOADS,点击MySQL Community (GPL) Downloads »
3.点击MySQL Community Server,点击Archives,选择数据库版本与操作系统,选择Windows (x86, 64-bit), ZIP Archive,点击Download
二、MySQL配置
1.解压下载的安装包
2.打开解压后的文件,新建文件my.ini
3.编辑配置文件
#配置mysql服务器端信息
[mysqld]
#配置服务器端口号
port=3307
#配置时区为东八区 在此处配置后连接mysql服务器时不必需要每次设置时区timezeServer=PRC
default-time-zone='+8:00'
#设置最大连接数
max_connections=200
#允许失败的连接次数,防止有人试图通过该主机攻击数据库系统
max_connect_errors=10
#服务器使用的默认字符集
character-set-server=utf8
#创建数据表的默认引擎
default-storage-engine=INNODB
#设置默认使用的插件认证 mysql_native_password/caching_sha2_password
#default_authentication_plugin=myql_native_password
#解决导入脚本时function错误(使用source错误和自定义函数错误)
#> 1418 - This function has none of DETERMINISTIC, NO SQL,
#or READS SQL DATA in its declaration and binary logging is enabled
#(you *might* want to use the less safe log_bin_trust_function_creators variable)
log_bin_trust_function_creators=1
#允许执行load data local infile 'c:/a.txt'
local-infile=1
#允许执行select * from XX into outfile 'c:/a.txt'
secure_file_priv=''
#配置mysql客户端信息
[mysql]
#设置默认字符集
default-character-set=utf8
#允许执行load data local infile 'c:/a.txt'
local-infile=1
#设置mysql客户端连接服务器 默认使用的端口 用户名 密码
[client]
port=3307
user=ys2
password=ys23345
三、安装MySQL
1.进入DOS命令窗口,选择MySQL解压文件下的bin文件夹,输入命令,进行初始化
无密码方式初始化
D:developdbmsmysql8.0.27bin>mysqld --initialize-insecure
初始化完成之后会在MySQL解压文件下生成一个data文件夹
2.创建MySQL服务,并启动服务
D:developdbmsmysql8.0.27>mysql -install mysql
启动服务
D:developdbmsmysql8.0.27bin>net start mysql
3.登陆MySQL数据库 mysql -h主机地址 -P端口号 -u账号 -p密码
D:developdbmsmysql8.0.27bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 21687
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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.停止服务
1.关闭服务
D:ys2developmysql8.0.27bin>net stop mysql
2.卸载服务
2.移除mysql
D:ys2developmysql8.0.27bin>mysqld -remove mysql
注意:
- mysql的安装与登陆行为都在mysql解压文件的bin目录下进行。
- mysql在登陆数据库时,采用 mysql -h主机地址 -P端口号 -u账号 -p密码 这种方式登陆会将密码暴露在控制台上,不安全。可以采用 mysql -h主机地址 -P端口号 -u账号 -p 不先输入密码,而是在下一行输入密码的方式进行登录。
- 在不指定主机地址和端口号的情况下 默认会从本地和3306端口登录。
- 如果在my.ini配置文件中,配置了要登陆的账号、密码及端口等等,登录时将会不需要指定,可能只输入mysql回车即可。
5.如果在服务启动后进行了配置文件的修改,则最好进行一次服务的重启操作。先停止服务,再开启服务。
以上在mysql8.0.27版本进行,mysql5.6以后版本安装时可直接略过初始化步骤,其余步骤不变。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。