AutoMySQLBackup遇到的几个问题

运维 数据库运维
使用AutoMySQLBackup备份MariDB时,手工执行shell脚本中的脚本 /mysql_backup/scripts/automysqlbackup /mysql_backup/scripts/conf/myserver.conf 没有问题。

 [[428182]]

本文转载自微信公众号「DBA闲思杂想录」,作者潇湘隐者。转载本文请联系DBA闲思杂想录公众号。

1:使用AutoMySQLBackup时遇到错误:Error: Dependency programs are missing. Perhaps they are not in $PATH. Exiting

使用AutoMySQLBackup备份MariDB时,手工执行shell脚本中的脚本 /mysql_backup/scripts/automysqlbackup /mysql_backup/scripts/conf/myserver.conf 没有问题。但是在作业(crontab)里面执行脚本时遇到下面错误:

  1. Note: Parsed config file /mysql_backup/scripts/conf/myserver.conf. 
  2. Note: /etc/automysqlbackup/automysqlbackup.conf was not found - no global config file. 
  3. Error: Dependency programs are missing. Perhaps they are not in $PATH. Exiting. 

出现这个问题,一般是由于环境变量引起的。需要修改配置文件myserver.conf中的参数PATH,使用命令ps -ef | grep -i mysqld 找到mysqldump所在的路径后,配置myserver.conf的参数PATH即可解决问题。

案例如下所示:

  1. Default values are stored in the script itself. Declarations in 
  2. # /etc/automysqlbackup/automysqlbackup.conf will overwrite them. The 
  3. # declarations in here will supersede all other. 
  4.  
  5. # Edit $PATH if mysql and mysqldump are not located in /usr/local/bin:/usr/bin:/bin:/usr/local/mysql/bin 
  6. #PATH=${PATH}:FULL_PATH_TO_YOUR_DIR_CONTAINING_MYSQL:FULL_PATH_TO_YOUR_DIR_CONTAINING_MYSQLDUMP 
  7. PATH=${PATH}:/app/mariadb/bin 

2:mysqldump: Couldn't execute 'SHOW FIELDS FROM xxx': View xxxx.xxxx' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)

AutoMySQLBackup其实是封装了mysqldump的一个shell脚本,在一个案例中,具体报错如下所示:

 

  1. ==================================================================================================================================== 
  2. ............................................................................................................................. 
  3. Errors reported during AutoMySQLBackup execution.. Backup failed 
  4. Error log below.. 
  5. mysqldump: Couldn't execute 'SHOW FIELDS FROM `xxx`': View xxxx.xxxx' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356) 
  6.  
  7. ............................................................................................................................. 
  8. ==================================================================================================================================== 

遇到这个问题,首先检查账号权限,AutoMySQLBackup使用的账号为dbbackup,具体权限如下所示,一般而言,这样的权限是没有问题的。

  1. GRANT SELECT, RELOAD, LOCK TABLES, REPLICATION CLIENT, SHOW VIEW, EVENT, TRIGGER ON *.* TO 'dbbackup'@'127.0.0.1'
  2. GRANT EXECUTE ON sys.* TO 'dbbackup'@'127.0.0.1'
  3. FLUSH PRIVILEGES

使用dbbackup登录MySQL,切换到对应用户数据库,执行下面命名时,还真遇到了权限问题。

  1. mysql> SHOW FIELDS FROM `xxx`; 
  2. ERROR 1356 (HY000): View 'xxx.xxx' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them 
  3. mysql> 

然后使用root账号查看视图定义

  1. mysql> show create view xxx\G; 

最后一一排查下来,发现是视图xxx中引用了一个Function,但是用户dbbckup没有这个函数的执行权限,所以报这个错误。授予用户下面权限后,问题解决

  1. GRANT EXECUTE ON xxx.* TO 'dbbackup'@'127.0.0.1'
  2. FLUSH PRIVILEGES

关于这个问题,还有可能是因为视图引用了无效的表,列或函数,而不一定是视图的定义者/调用器缺乏调用它们的权限。

 

责任编辑:武晓燕 来源: DBA闲思杂想录
相关推荐

2022-05-24 16:09:38

前端脚本

2013-05-06 15:42:49

2021-03-03 21:24:57

数据仓库工具

2009-09-07 14:39:14

2011-05-18 11:31:56

数据安全数据备份

2011-07-01 09:31:49

.net

2010-06-09 16:57:14

路由选择协议

2017-11-28 10:34:47

数据中心迁移IDC

2017-11-20 10:45:26

数据中心迁移IDC

2011-07-04 16:40:39

QT 串口 QML

2021-01-19 08:25:20

Java反射进阶

2013-11-12 09:16:00

SDN思科Insieme

2009-11-06 14:07:58

Oracle用户表空间

2022-01-12 08:53:04

数字化疫情企业发展

2013-08-29 09:47:32

开源hypervisor

2011-09-14 15:23:00

Android 2.2

2019-01-29 07:44:14

2009-08-05 18:47:55

ASP.NET服务器

2015-09-17 10:51:35

修改hostnameLinux

2019-01-07 14:36:36

Go系统开源库
点赞
收藏

51CTO技术栈公众号