欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mysql安装配置

程序员文章站 2022-04-13 21:31:46
...

本来不打算写的,但是最近又安装了一次,每次安装都得百度一遍。。。所以还是自己写一篇,下次安装也不用再找别人的。。

1.下载

2.配置系统变量

MYSQL_HOME:D:\Java\mysql-8.0.18-winx64

Path变量里加上 %MYSQL_HOME%\bin

mysql安装配置

mysql安装配置

3.新建一个my-default.ini文件

mysql安装配置

内容如下:

# 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.

[mysqld]

# 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.
port=3306
basedir=D:\Java\mysql-8.0.18-winx64
datadir=D:\Java\mysql-8.0.18-winx64\data
# port = .....
# 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 = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

4.安装。。。

必须用管理员身份打开命令行。。

 1)mysqld --initialize --console   

 这个命令会生成3中的data文件夹,所以如果安装失败重新安装的时候,执行此命令前先删掉data文件夹

mysql安装配置

这里红框部分是初始密码,第四步会用上

2) mysqld install mysql  

这个命令的mysql是一个mysql服务代号,如果mysql已经存在,执行1)的时候会生成mysql2,因此这里的命令就要用对应的net install mysql2, 这里如果想删掉mysql2, 可以执行 mysqld -remove mysql2

3) net start mysql 

启动mysql服务

4)登录mysql并修改密码

 mysql -u root -p 

  输入刚刚1)中的密码....

mysql安装配置

修改密码: ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; // 记住你的密码是123456

退出: exit;

完成。。。。。

相关标签: 软件安装 mysql