全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2568|回复: 4

[Windows VPS] 请教技术帝,执行这个mysql备份脚本为什么提示1045错误?

[复制链接]
发表于 2012-4-26 10:04:26 | 显示全部楼层
何必这么麻烦,直接用mysqldump啊
 楼主| 发表于 2012-4-26 10:07:17 | 显示全部楼层
完美 发表于 2012-4-26 09:58
用phpmyadmin试试登陆

登陆phpmyadmin是没问题的。
发表于 2012-4-26 09:42:24 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2012-4-26 09:58:39 | 显示全部楼层
用phpmyadmin试试登陆
 楼主| 发表于 2012-4-26 09:40:04 | 显示全部楼层 |阅读模式
  1. #!/bin/sh
  2. # mysql_backup.sh: backup mysql databases and keep newest 5 days backup.
  3. #
  4. # Last updated: 20 March 2006
  5. # ----------------------------------------------------------------------
  6. # This is a free shell script under GNU GPL version 2.0 or above
  7. # Copyright (C) 2006 Sam Tang
  8. # Feedback/comment/suggestions : http://www.real-blog.com/
  9. # ----------------------------------------------------------------------
  10. # your mysql login information
  11. # db_user is mysql username
  12. # db_passwd is mysql password
  13. # db_host is mysql host
  14. # -----------------------------
  15. db_user="root"
  16. db_passwd="123456"
  17. db_host="localhost"
  18. # the directory for story your backup file.
  19. backup_dir="/home/www"
  20. # date format for backup file (dd-mm-yyyy)
  21. time="$(date +"%d-%m-%Y")"
  22. # mysql, mysqldump and some other bin's path
  23. MYSQL="/usr/local/mysql/bin/mysql"
  24. MYSQLDUMP="/usr/local/mysql/bin/mysqldump"
  25. MKDIR="/bin/mkdir"
  26. RM="/bin/rm"
  27. MV="/bin/mv"
  28. GZIP="/bin/gzip"
  29. # check the directory for store backup is writeable
  30. test ! -w $backup_dir && echo "Error: $backup_dir is un-writeable." && exit 0
  31. # the directory for story the newest backup
  32. test ! -d "$backup_dir/backup.0/" && $MKDIR "$backup_dir/backup.0/"
  33. # get all databases
  34. all_db="$($MYSQL -u $db_user -h $db_host -p$db_passwd -Bse 'show databases')"
  35. for db in $all_db
  36. do
  37. $MYSQLDUMP -u $db_user -h $db_host -p$db_passwd $db | $GZIP -9 > "$backup_dir/backup.0/$time.$db.gz"
  38. done
  39. # delete the oldest backup
  40. test -d "$backup_dir/backup.5/" && $RM -rf "$backup_dir/backup.5"
  41. # rotate backup directory
  42. for int in 4 3 2 1 0
  43. do
  44. if(test -d "$backup_dir"/backup."$int")
  45. then
  46. next_int=`expr $int + 1`
  47. $MV "$backup_dir"/backup."$int" "$backup_dir"/backup."$next_int"
  48. fi
  49. done
  50. exit 0;
复制代码
执行后提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
检查了N遍,确定db_passwd参数没错。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-6-17 10:37 , Processed in 0.089439 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表