mysql8.0.20免安装初始化步骤记录

一.新增my.ini

文件内容如下:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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.
 
[mysqld]
#skip-grant-tables 
# 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 = .....
# datadir = .....
# port = .....
# server_id = .....
basedir ="C:\MySql\mysql-8.0.20-winx64   # 设置mysql的安装目录 
datadir ="C:\MySql\mysql-8.0.20-winx64\data"   # 设置mysql数据库的数据的存放目录,必须是data,或者是//xxx/data  
 
 
# 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 = 2M
# read_rnd_buffer_size = 2M 
 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
 
#服务端的编码方式
character-set-server=utf8mb4
[client]
#客户端编码方式,最好和服务端保存一致
loose-default-character-set=utf8mb4
 
[WinMySQLadmin]  
Server = "C:\MySql\mysql-8.0.20-winx64\bin\mysqld.exe"

二.修改环境变量

计算机——属性——高级系统设置——环境变量
选择path新增mysql安装bin目录路径

三.初始化

在bin目录下cmd运行

3.1.mysqld --initialize --console

执行过后找到A temporary password is generated for root@localhost: 这句,localhost后面就是自己的初始化密码。

若此时弹出缺少MSVCP140.dll,安装VC_redist.exe。

mysql初始化报错
若报错ound option without preceding group in config file:,将my.ini文件编码方式由utf-8改为ANSI
在这里插入图片描述

3.2.net start mysql

启动服务,则输入

若服务名无效
输入 mysqld --install

若要删除mysql,可执行命令

mysqld --remove mysql

3.3.mysql -u root -p

进行登录数据库,这时提示需要密码,然后就是用上面的密码登录

3.4.修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

修改密码为:123456

四.新增账户

create user 'demo'@'%' identified with mysql_native_password BY '123456';

五.修改权限:

grant all privileges on  *.*  to 'demo'@'%' with grant option;

六.刷新

flush privileges;

七.备份

mysqldump -udemo -p123456 demo table >baktable.sql;
--single-transaction  锁定数据库防止其他事物操作导致数据不一致
### 七.导入库
source

七.删除库

drop database demo;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值