Mysql登录问题

The user specified as a definer (‘root’@’%’) does not exist

在使用mysql视图是出现问题: The user specified as a definer ('root'@'%') does not exist。
一般是由于root用户对全局host无访问权限。因此只要给root用户添加一个访问权限即可。
解决办法:
登陆mysql ,执行
mysql -u root -pPasswd
mysql >grant all privileges on *.* to root@"%" identified by "Passwd"
mysql >flush privileges

[来自](http://blog.csdn.net/b422761838/article/details/8621124)

MYSQL ERROR 1045 (28000): Access denied for user (using password: YES)

[root@228827 ~]# /etc/init.d/mysql stop    
[root@228827 ~]# /usr/local/mysql/bin/mysqld_safe –skip-grant-tables &
[root@228827 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.1.57 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> use mysql
Database changed
mysql> select user,host,password from user where user='root';
+——+——————-+——————————————-+
| user | host | password |
+——+——————-+——————————————-+
| root | % | *A50E066E106320CF4142 |
| root | centos | *A50E066E106320CF4142 |
| root | 127.0.0.1 | *A50E066E1063608320CF4142 |
+——+——————-+——————————————-+
3 rows in set (0.12 sec)
发现user表host字段中没有localhost,但是我的理解是%代表所有的主机都能登录的,为什么localhost不能呢,同样的情况我在5.0.45版的mysql上面做实验就不会发生localhost无法登录,我当前用的是5.1.57版的,难道是版本的问题?
接下来的修改很明显了:
mysql> update user set host='localhost' where user='root' and host='%'; 
mysql> flush privileges;
来自 <http://www.111cn.net/database/mysql/49938.htm> 

这里记录一下今天遇到的纠结事情:

首先kill掉MySQL进程然后在启动mysql的参数中加入

跳过登录
--skip-grant-tables(windows)
来自 <http://www.111cn.net/database/mysql/49938.htm> 

允许root用户在一个特定的IP进行远程登录,并具有所有库任何操作权限,具体操作如下: 
在本机先使用root用户登录mysql: 
mysql -u root -p"youpassword" 
进行授权操作: 
GRANT ALL PRIVILEGES ON *.* TO root@"172.16.16.152" IDENTIFIED BY "youpassword" WITH GRANT OPTION; 
重载授权表: 
FLUSH PRIVILEGES; 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值