1、修改user表的root用户的Host为%mysql>showdatabases;+--------------------+|Database|+--------------------+|information_schema||mysql||performance_schema||sys|+--------------------+4rowsinset(0.00sec)mysql>usemysql;mysql>selectHost,Userfromuser;+-----------+---------------+|Host|User|+-----------+---------------+|localhost|mysql.session||localhost|mysql.sys||localhost|root|+-----------+---------------+3rowsinset(0.00sec)mysql>updateusersetHost='%'whereUser='root';QueryOK,1rowaffected(0.01sec)Rowsmatched:1Changed:1Warnings:0mysql>selectHost,Userfromuser;+-----------+---------------+|Host|User|+-----------+---------------+|%|root||localhost|mysql.session||localhost|mysql.sys|+-----------+---------------+3rowsinset(0.00sec)mysql>flushprivileges;QueryOK,0rowsaffected(0.79sec)mysql>2、直接命令修改mysql>GRANTALLPRIVILEGESON*.*TO'root'@'%'IDENTIFIEDBY'密码';mysql>flushprivileges;这一步一定要做,不然无法成功!这句表示从mysql数据库的grant表中重新加
未分类