在Linux系统中安装MySQL,初始话失败,报错信息如下:
WARNING: The host ‘Power1‘ could not be looked up with resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MySQL version. The MySQL daemon, mysqld, should work normally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnames when specifying MySQL privileges !
1.从报错信息看,是数据库无法解析机器名,排查过程如下:
使用resolveip查看IP是否正常
[root@Power1 ~]# /usr/local/mysql/bin/resolveip Power1 /usr/local/mysql/bin/resolveip: Unable to find hostid for ‘Power1‘: host not found
2.查看机器名
[root@Power1 ~]# hostname Power1
3.查看/etc/hosts文件
[root@Power1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
查询结果可见/etc/hosts中无相应的机器名Power1
添ip(本机的ip) 到机器的对应到/etc/hosts中,最终显然如下:
[root@Power1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.20.131 Power1
4.使用resolveip确认是否ok
[root@Power1 ~]# /usr/local/mysql/bin/resolveip Power1 IP address of Power1 is 192.168.20.131
5.重新初始化
原文地址:http://00127129.blog.51cto.com/10552428/1679241