1.先看下mysql是否设置了环境变量,若是没设置,就须要切换到mysql的bin目录下执行命令mysql
mysql -hlocalhost -uroot -p123456
2.给root用户添加权限sql
mysql8.0之前的版本能够使用grant在受权的时候隐式的建立用户,8.0之后已经不支持,因此必须先建立用户,而后再受权,命令以下:ide
CREATE USER 'root'@'%' IDENTIFIED BY '123456'加密
grant all privileges on *.* to 'root'@'%'; flush privileges; 若是远程链接的时候报plugin caching_sha2_password could not be loaded这个错误,能够尝试修改密码加密插件: alter user 'root'@'%' identified with mysql_native_password by '123456';