window mysql下载与安装

1、下载mysql

官网下载地址:
https://dev.mysql.com/downloads/mysql/
这里写图片描述
直接选zip的免安装版。

2、安装

2.1、 解压

解压到任意目录就可以,比如D:\soft\mysql-8.0.11-winx64

2.2、新建my.ini启动文件

在mysql根目录下建立my.ini文件,如D:\soft\mysql-8.0.11-winx64\my.ini
data存放的路劲一定不要自已建立,直接用mysql默认安装目录下的data目录即可。

[client]
port=3309
default-character-set=utf8
[mysqld]
port=3309
character_set_server=utf8
#安装路径
basedir=D:\\soft\\mysql-8.0.11-winx64
#数据路径
datadir=D:\\soft\mysql-8.0.11-winx64\\data
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
D:\\soft\\mysql-8.0.11-winx64\\bin\\mysqld.exe

如果你想修改,可参考官网:
https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html
这里写图片描述
新建my.ini文件注意,先直接建立my.txt文件,编辑完成后另存为my.ini文件即可,注意保存格式为ANSI

3、添加环境变量(可选)

添加D:\soft\mysql-8.0.11-winx64\binmysql bin 目录到path环境变量后面

4、安装

打开cmd命令窗口,必须用管理员权限打开
a、Initializing the Data Directory

mysqld --initialize-insecure --user=mysql

建议用这个命令,root登录的时候不用密码。如果用mysqld --initialize那么登录时,还要到错误日志中找root随机生成的密码。
如果出现错误:
这里写图片描述
那么注意查看my.ini文件格式,重新另存为修改格式为ANSI
b、安装命令

 mysqld install MySQL --defaults-file="D:/soft/mysql-8.0.11-winx64/my.ini"

c、启动服务

net start mysql

#### 5、设置密码
1、 mysqld –initialize方式:
a、If you do not know the initial random password, look in the server error log.
b、Connect to the server as root using the password:

shell> mysql -u root -p
Enter password: (enter the random root password here)

c、Choose a new password to replace the random password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

2、mysqld –initialize-insecure方式
a、Connect to the server as root using no password:

shell> mysql -u root --skip-password

b、Assign a password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

6、命令

登录命令:

shell> mysql -u root -p
Enter password: (enter root password here)

关闭服务命令:

shell> mysqladmin -u root -p shutdown
Enter password: (enter root password here)

7、navicat连接配置

安装好mysql-8.0.11后用navicat联连报错:

1251 Client does not support authentication protocol requested by server; consider upgrading MySQL client

看很多解决方式都是5.0版本的。8.0的解决方式:

mysql> UPDATE mysql.user SET plugin = 'mysql_native_password';
mysql>alter user '用户名'@localhost IDENTIFIED WITH mysql_native_password by '你的密码';

这里写图片描述
再连接navicat成功。

参考官网:
https://dev.mysql.com/doc/refman/8.0/en/windows-install-archive.html

猜你喜欢

转载自blog.csdn.net/lh87270202/article/details/80404608