无脑Mysql安装教程
1.去官网下载Mysql
2.解压Mysql
在电脑上随便找一个位置创建个文件夹,将mysql解压到里面即可
(建议D盘)
3.配置环境变量
复制解压后mysql的bin路径,然后配置环境变量
在path路径新建一个,直接将路径输入即可
4.修改配置文件
找到刚才解压mysql的目录文件
修改my.ini配置文件
主要就是修改里面的basedir与datadir
如果没有就手动添加
basedir:设置为你的mysql的安装目录
datadir:设置为你的数据存放目录
目录位置直接找到文件夹复制即可
4.1 安装的是8.0以上的Mysql的zip安装包的
8.0版本及以上的zip安装一般没有data文件夹和my.ini文件,这时就要自己创建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]
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.
#这里是mysq的安装路径和数据存放位置,如上
basedir = D:\MySQL
datadir = D:\MySQL\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
配置之后在cmd(管理员身份)执行以下命令
该命令会重新生成data文件夹
mysqld --initialize-insecure --user=mysql
5.运行CMD(win+R,输入cmd回车确认即可)
以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够)
输入cd命令跳转到mysql的bin目录
6.执行命令
1.输入安装命令
mysqld --install --defaults-file="d:/mysql/my.ini"
defaults-file绑定的是刚才配置的my.ini文件的路径
如果执行成功就会显示
2.启动服务,输入
net start mysql
3.服务启动,输入
mysql -u root -p
第一次登录没有密码,直接按回车过
回车后显示mysql> 即代表创建成功
4.成功进入后可以修改mysql密码
alter user 'root'@'localhost' identified by '123456';
by后面就是要修改成的密码