問題:
1钞钙,My.cnf中用戶名密碼無效
使用Zabbix監(jiān)控mysql中退敦,發(fā)現(xiàn)在/usr/local/mysql/my.cnf里面設(shè)置的默認用戶名密碼無效,出不來數(shù)據(jù)汁政,而且在zabbix服務(wù)器上,使用zabbix_get也報錯failed缀旁,如下
#/usr/local/zabbix/bin/zabbix_get -s 192.168.13.13 -p10050 -k mysql.status[Uptime]
/usr/local/mysql/bin/mysqladmin: connect toserver at 'localhost' failed
error: 'Access denied for user'adminuser'@'localhost' (using password: NO)'
解決方式:
由于是二進制包安裝的记劈,默認的配置文件路徑在/usr/local/mysql/my.cnf,但是mysqladmin識別的my.cnf路徑中(/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf )并巍,并不存在/usr/local/mysql/my.cnf目木,解決過程選擇一個/usr/local/mysql/etc/my.cnf,然后新建并且在里面錄制好用戶名密碼懊渡,然后調(diào)試通過
# 在mysql服務(wù)器上面準(zhǔn)備新的配置文件my.cnf
# mkdir /usr/local/mysql/etc
# vim /usr/local/mysql/etc/my.cnf
[mysqladmin]
user=zabbix
password=ys_test0418
socket=/usr/local/mysql/mysql.sock
# 賦予mysql用戶訪問權(quán)限
# chown -R mysql.mysql /usr/local/mysql/etc/my.cnf