Mysql官网下载地址:https://downloads.mysql.com/archives/community/
安装步骤
1.解压下载好的mysql-5.7.20-winx64,将文件夹剪切到安装目录下。
2.到bin目录下,目录选中状态输入cmd,打开命令提示框。
3.安装数据库【一般都会成功】:mysqld install
官网下载地址:https://www.microsoft.com/zh-cn/download/details.aspx?id=40784
下载完成之后安装
4.启动服务:net start mysql
不能启动的情况下:
以管理员身份打开cmd尝试启动服务,如果不行在命令行数据mysqld --initialize
检查错误原因。
可能缺少my.ini文件
缺少data文件夹
5.先在安装目录下找到 data 文件夹(没有就创建,有就清空)
此时只需要执行一句指令:mysqld --initialize-insecure --user=mysql
配置环境变量
右击计算机 => 属性 =>高级系统设置 => 环境变量 =>系统变量
新建:MYSQL_HOME:D:\mysql-5.7.20-winx642
编辑 path 系统变量: %MYSQL_HOME%\bin
后期如要该数据库,直接更改:MYSQL_HOME的值。
添加配置文件
在根目录下查看是否有my.ini配置文件,如果没有创建,复制以下代码,到创建的my.ini文件中。
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
#跳过密码
skip-grant-tables
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir =D:\mysql-5.7.20-winx64
datadir = D:\mysql-5.7.20-winx64\\data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
修改mysql密码
1.在数据库根目录下粘贴数据库文件:my.ini,其里面设置可跳过密码验证进入数据库。
2.打开数据库mysql -uroot -p:
,输入密码直接回车就进入mysql数据库了。
3.注释掉my.ini中设置的跳过密码验证。
4.刷新配置:flush privileges
5.修改密码:set password for 'root'@'localhost' = password('123456')
6.退出数据库:quit
7.打开数据库测试修改密码成功:mysql -uroot -p123456
网友评论