1 在终端 通过service mysqld stop(或者 killall -TERM Mysql)停止mysql的服务 2 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables& 跳过安全检验机制(此时不要关闭当前终端,另开新的终端) 3 update user set password=password('root') where user='root'; 4 flush privileges; 5 重启mysql服务 service mysqld stop; 如果无法重启,可以ps -ef|grep mysql 之后kill 进程,重新 重启; 本地工具连接数据库 出现 host is not allowed to connect to this mysql 1。 改表法。 可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%" mysql -u root -pvmwaremysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user; 2. 授权法。 在安装mysql的机器上运行: 1、d:\mysql\bin\>mysql -h localhost -u root //这样应该可以进入MySQL服务器 2、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //赋予任何主机访问数据的权限 3、mysql>FLUSH PRIVILEGES //修改生效 4、mysql>EXIT //退出MySQL服务器 之后就可以连接数据库了。
linux下设置mysql用户名及密码基本方法 以及解决 host is not allowed to connect to this mysql
0票
开心
0票
板砖
0票
感动
0票
有用
0票
疑问
0票
难过
0票
无聊
0票
震惊
顶
踩