保姆级 | MySQL的安装配置教程(非常详细)
一、下载Mysql
从官网下载MySQL,这里我选用的是Mysql8.0.34版本
![](https://img.shuduke.com/static_img/cnblogs/80/rddtmjna_7oz6.webp)
![](https://img.shuduke.com/static_img/cnblogs/80/phphkqkl_bl92.webp)
![](https://img.shuduke.com/static_img/cnblogs/80/usglzcqs_z3d3.webp)
二、安装Mysql
下载完成后直接双击进行安装,打开后的页面如下所示:
选择自定义custom,接着下一步
![](https://img.shuduke.com/static_img/cnblogs/80/buyapely_9j7h.webp)
![](https://img.shuduke.com/static_img/cnblogs/80/pmwwxyhv_1tf4.webp)
![](https://img.shuduke.com/static_img/cnblogs/80/qeiychya_53tp.webp)
![](https://img.shuduke.com/static_img/cnblogs/80/mlsishpn_w1p7.webp)
选好后点击OK,然后点击Next
![](https://img.shuduke.com/static_img/cnblogs/80/aqyfcdjy_efat.webp)
然后等待运行完成,然后连续点击下一步
![](https://img.shuduke.com/static_img/cnblogs/80/hnbuznki_lu0z.webp)
到这里也不需要修改任何内容,继续下一步
![](https://img.shuduke.com/static_img/cnblogs/80/hlikqapf_68vb.webp)
这里一般选择传统密码,看个人习惯。然后接着next
![](https://img.shuduke.com/static_img/cnblogs/80/nwnmfaiq_mku3.webp)
这里设置自己的mysql密码,确认好了点击Next即可
![](https://img.shuduke.com/static_img/cnblogs/80/fzpaqimu_7w8s.webp)
![](https://img.shuduke.com/static_img/cnblogs/80/ixpjbeow_i1yo.webp)
继续下一步,不作修改。
![](https://img.shuduke.com/static_img/cnblogs/80/pjoqxypy_54tj.webp)
点击Execute进行执行(需要等待一小会儿)
![](https://img.shuduke.com/static_img/cnblogs/80/wtouirgt_u9f9.webp)
执行完成点击Finish即可,然后点击next,再点击Finish即可
到这已实现了Mysql的安装
三、配置Mysql
安装好之后,在桌面右键点击我的电脑(有些是此电脑),然后点击属性,进入系统信息设置
![](https://img.shuduke.com/static_img/cnblogs/80/repoavub_pzjc.webp)
接着点击高级,进入环境变量界面
![](https://img.shuduke.com/static_img/cnblogs/80/snnfunli_1gcu.webp)
进入环境变量界面
![](https://img.shuduke.com/static_img/cnblogs/80/xhogpudp_etpg.webp)
编辑path变量
![](https://img.shuduke.com/static_img/cnblogs/80/dmatyydc_qxf8.webp)
然后点击确定,再确定即可
接着按住win+r ,输入cmd
![](https://img.shuduke.com/static_img/cnblogs/80/xxkfllay_3eh9.webp)
然后输入命令行
mysql -u root -p
![](https://img.shuduke.com/static_img/cnblogs/80/dpkysqvm_mhz2.webp)
当输入mysql的密码后。出现了mysql的版本信息即说明配置成功了。
mysql密码即是你安装MySQL时设置的密码
到这里算是可以正常使用MySQL了。但是如果每次输入sql语句时,都要使用命令行的模式输入命令来使用,未免也太枯燥了点。所以就出现了连接数据库的可视化工具,具体可以看第四章
四、连接Mysql
连接数据库的可视化工具有很多。有mysql官方的mysql workbench,有DataGrip,还有navicat等等。
这里我选用的是navicat,这是市面上比较常用的工具。
这个工具官方下载是会收费的,免费版本可以关注 V公众号 星浩工具站,输入navicat进行领取
下载之后找到对应目录,找到对应exe可执行文件
![](https://img.shuduke.com/static_img/cnblogs/80/ipiwvooa_7ey8.webp)
双击exe可执行文件
![](https://img.shuduke.com/static_img/cnblogs/80/uyksufsf_z506.webp)
然后点击连接,再选择Mysql。接着输入对应的参数即可
![](https://img.shuduke.com/static_img/cnblogs/80/txosmxrb_tiot.webp)
然后点击确定。如果说不记得密码,可以点击连接测试进行测试密码正确与否。
接着我们就成功连接上数据库了
![](https://img.shuduke.com/static_img/cnblogs/80/mmmlubjf_krr0.webp)
这里的mysql之类的数据库文件不要随便删除。
如果要新建数据库,可以右键对应的连接,然后点击新建数据库即可
五、部分疑难问题
报错内容:2058(Plugin caching_sha2_password could not be loaded:)
![](https://img.shuduke.com/static_img/cnblogs/80/oyaaxvic_cczi.webp)
【可能原因】Mysql新版默认使用 caching_sha2_pasword 作为 身份验证插件。而旧版是使用 mysql_native_password,当连接MySQL时报错 plugin caching_sha2_password could not be loaded 时,可换回旧版插件。
【处理办法】通过命令提示符cmd登录MySQL,然后输入命令。
【解决步骤】
1、打开cmd(win+R),输入:mysql -u root -p
进入MySQL
2、进入mysql,执行下面语句:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
(其中123456是你预设置的root密码,我的密码是:123456
![](https://img.shuduke.com/static_img/cnblogs/80/ovmqcguv_jhsl.webp)
然后再次使用navicat连接Mysql可以发现问题已经得到解决了