今天开始正式接触MySQL,虽然很多人都觉得数据库学起来很简单,但我学东西一向比较吃力,在此记录一下,鼓励自己坚持下去。
1、安装
先在官网上下载下windows下的免安装文件 .zip格式的。解压到E:\programinstall\mysql-8.0.11-winx64\bin
进入cmd以管理员身份运行
进入E:\programinstall\mysql-8.0.11-winx64\bin



这三步是必须的,还有配置my.ini文件,我没弄,好像也不影响使用,出现问题再说。还有就是

这一步我弄得糊里糊涂的,好像弄了又好像没弄,以后出现问题再说。
密码为空,直接回车登录MySQL

查询用户密码
输入:select host,user,authentication_string from mysql.user;

host: 允许用户登录的ip‘位置’%表示可以远程;
user:当前数据库的用户名;
authentication_string: 用户密码(后面有提到此字段)
观察到root用户下的authentication_string是为空的,如果不是空,设为空,方法:
use mysql;
update user set authentication_string='' where user='root';

修改密码: ALTER user 'root'@'localhost' IDENTIFIED BY '123456';

MySQL安装和修改密码阶段结束。
使用Navicat连接MySQL报错2059,这是由于新版本的MySQL使用的是caching_sha2_password验证方式,但此时的navicat还没有支持这种验证方式。解决方法就是将验证方式改为以前版本(5.7及以下)使用的验证方式mysql_native_password。
mysql> use mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> FLUSH PRIVILEGES;

成功!!完美了!!
退出MySQL : mysql>exit;
关闭mySQL:E:\programinstall\mysql-8.0.11-winx64\bin>net stop mysql
我没有配环境变量。
网友评论