mysql免安装版配置

一、下载免安装版mysql:https://file.nsk666.com/d/share/developTool/DataBase/mysql-5.7.24-winx64.zip

  • 也可以去官网下载!

二、配置环境变量:

  • 在path中添加:H:\DataBase\mysql-5.7.23\bin    (H:\DataBase\mysql-5.7.23为解压路径)

三、新建编写my.ini

  • 在mysql路径文件下新建my.ini,设置data的存放地址

image.png

# 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 ="H:\DataBase\mysql-5.7.23"   # 设置mysql的安装目录 
datadir ="H:\DataBase\mysql-5.7.23\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 = "H:\DataBase\mysql-5.7.23\bin\mysqld.exe"

三、打开cmd初始化sql服务(管理员模式运行cmd)

  • mysqld --install

image.png

  • 初始化(如果二次初始化,注意先把data文件夹里面的内容清空)

  • mysqld --initialize --console

image.png

  • 上面的 root@localhost: IX)*yuDi7.&L  是默认密码。

四、启动MySQL,登录mysql

  • 启动: net start mysql

image.png

  • 登录: mysql -u root -p

  • 然后输入刚刚的默认密码

  • SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘123456’);  
    吧密码修改成123456

  • 或者 ALTER USER USER() IDENTIFIED BY ‘o!k?T7ZDGZ>D’;

  • flush privileges;

  • 刷新下

image.png结束:!