use mysql;select host,userfromuser;# 配置root远程登录updateuserset host='%'whereuser='root';# 配置root用户密码为123456alteruser root@'%' identified with mysql_native_password by'123456';# 退出mysql命令行exit;
# 使用root账号密码登录
mysql -u root -p# 如果出现报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)使用一下命令
mysql -u root -h127.0.0.1 -p