一:安装
1.首先肯定要去官网下载。
下载地址是:https://dev.mysql.com/downloads/mysql/
找到最新的版本,要之前的版本也可以自己找
2.将解压文件解压到自己想要的目录:E:\mysql(这是我放在E盘根目录并且命名为mysql(方便之后cmd进入mysql),不要放在有中文名字和空格的的目录下)。
3.在E:\mysql文件夹下面新建一个my.ini文件(我是已经配置好的mysql,可以用新建文本文档修改得,但要记得后缀是ini而不是文本文档的txt)
4.在my.ini里面内容:(记得要改里面的文件夹的路径,因为是我的MySQL路径)
[mysqld]
character-set-server=utf8
#绑定IPv4和3306端口
bind-address = 0.0.0.0
port = 3306
sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
default_storage_engine=innodb
innodb_buffer_pool_size=1000M
innodb_log_file_size=50M
# 设置mysql的安装目录
basedir=E:\mysql
# 设置mysql数据库的数据的存放目录
datadir=E:\mysql\data
# 允许最大连接数
max_connections=20
# skip_grant_tables
[mysql]
default-character-set=utf8
[mysql.server]
default-character-set=utf8
[mysql_safe]
default-character-set=utf8
[client]
port = 3306
plugin-dir=E:\mysql\lib\plugin
然后另存为,记得要编码格式要是ANSI。(其实我第一次直接保存也成功了。。但后来网上找修改my.ini导致MySQL直接无法启动搞得原因时都说是没有保存为ANSI这个编码格式所以无法启动)
5.配置系统环境
在系统变量新建
6.以管理员的身份打开cmd窗口跳转路径到E:\mysql\bin(先输入E:回车,再输入cd mysql\bin)(看自己文件路径自由变换)
初始化命令:mysqld --initialize --user=mysql --console
(已经生成了密码,初始化后还是没找到密码的话可以在E:\mysql\data里找到err后缀的文件用文本文档打开查看,一般在root@localhost:后面)
添加服务:mysqld -install
启动服务:net start mysql
启动MySQL:mysql -uroot -p(然后输入前面查找到的的密码)
(这个图片是偷别人的,所以路径不一样。)
7.修改密码:
ALTER USER root@localhost IDENTIFIED BY '123456';(代表密码是123456,可自行修改)
二:进入navicat出现1251-Client does not support authentication protocol requested by server;的错误情况。
1.进入MySQL:
cmd管理员模式进入
输入E: 回车
输入cd mysql\bin 回车
输入mysql -uroot -p 回车
输入密码123456 回车
C:\WINDOWS\system32>E:
E:\>cd mysql\bin
E:\mysql\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.18 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
如下图:
2.更改加密方式
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.10 sec)
3.更改密码(密码可自行选择)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.35 sec)
4.刷新权限
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.28 sec)
再度进入navicat,成功。
自己的经验,自己由于作死修改my.ini坏过好几次(百度怎么修改再尝试),安装过好几次,写在这里记录一下,接受提议,不对勿喷。
参考文献:
https://www.cnblogs.com/tangyb/p/8971658.html
https://blog.csdn.net/maximeete/article/details/82192072
https://blog.csdn.net/belug/article/details/81081040