mysql8.0和mysql5.6安装配置及修改密码

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

1.下载

https://downloads.mysql.com/archives/installer/

2.配置系统变量

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

Path变量里加上 %MYSQL_HOME%\bin

mysql8.0和mysql5.6安装配置及修改密码_第1张图片

mysql8.0和mysql5.6安装配置及修改密码_第2张图片

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

mysql8.0和mysql5.6安装配置及修改密码_第3张图片

内容如下:

# 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文件夹

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

2) mysqld install mysql  

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

3) net start mysql 

启动mysql服务

4)登录mysql并修改密码

 mysql -u root -p 

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

mysql8.0和mysql5.6安装配置及修改密码_第4张图片

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

退出: exit;

完成。。。。。

 

由于版本可能不一样,还有一种情况是:(这是安装mysql5.6的方式,以上是mysql8.0)

执行完mysqld --initialize --console出现的是以下情况,注意,这种情况下初始密码为空,直接回车就行

mysql8.0和mysql5.6安装配置及修改密码_第5张图片

 按回车登录成功之后修改密码:

set password for root@localhost = password('123456');

mysql8.0和mysql5.6安装配置及修改密码_第6张图片

反正就是很奇葩。。。将就着用吧,还能删咋的。。。。

你可能感兴趣的:(软件安装)