今天遇到个很奇怪的问题,cacti是很早之前搭建的,一直没什么问题,突然有一天老大和我要流量的时候,发现cacti的登录界面突然报这个错误
FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'
然后去百度,谷歌查了好久,都没有解决我的问题,我开始怀疑我cacti的mysql用户没权限,然后准备再赋权看看
之后赋权的时候会报这个错,
ERROR 1045 (28000): Access denied for user (using password: YES)
很头疼,突然灵机一动,登录到另一台mysql服务器,其实对比起来很简单
>use mysql
>show tables; (user表里就是mysql内的用户信息)
>select * from user\G (对比其它数据库的用户信息,只看root用户即可)
发现root用户的Host只有 % 这个,没有其它的 localhost 127.0.0.1 主机名
这样就简单多了
>grant all on *.* to " identified by 'password';
>grant all on *.* to root@"127.0.0.1" identified by 'password';
>grant all on cactidb.* to identified by '1234';(给cacti用户赋权)
>flush privileges;
然后重启下mysql;再登录cacti,搞定!!!~~~
如果还是不行的话,可以自己对比下mysql库user表里root用户各Host的 Grant权限
和正常使用mysql库值不一样的 用update语句改下