mysql授权报错

时间:2023-03-10 05:05:19
mysql授权报错

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<zabbix>';
ERROR 1044 (42000): Access denied for user 'root'@'127.0.0.1' to database 'zabbix'
是因为mysql数据库的user表里,存在用户名为空的账户即匿名账户,导致登录的时候是虽然用的是root,但实际是匿名登录的,通过错误提示里的''@'localhost'可以看出来。

在my.ini的[mysqld]字段加入: skip-grant-tables

重启mysql服务,这时的mysql不需要密码即可登录数据库
然后进入mysql

mysql>use mysql;
mysql>update user set password=password('新密码') WHERE User='root';
mysql>flush privileges;

运行之后最后去掉my.ini中的skip-grant-tables,重启mysqld即可。

一:

-- MySQL 5.5.22
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/mysql-5.5.22

####出现此类报错,yum -y install bison后,删除rm CMakeCache.txt再编译即可,