PS:按照加粗字体操作,即可解决,其他内容记录下遇到的坑。
1.根据介绍,该问题是由于root用户没有赋权导致。
进行赋权操作:
首先登陆服务器:在cmd命令行(管理员身份),输入命令:mysql -uroot -p ;输入密码进入mysql。
网上大部分介绍使用命令:
grant all privileges on . to root@‘localhost’ identified by “123456”;赋权操作。
输入完命令后,遇到报错:1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘identified by ‘123456’’ at line 1。#该报错说我的语法错误。
后来将该命令改为:
#创建用户
CREATE USER ‘root’@’%’ IDENTIFIED BY ‘123456’;
#给用户赋值,(只使用这条命令,就可以对 mysql 8的root用户赋值成功)
alter user ‘root’@’%’ identified with mysql_native_password by ‘123456’;
赋值成功后,使用命令:**flush privileges;**进行权限刷新,就可以解决了!