VPS侦探论坛

 找回密码
 注册
查看: 5305|回复: 2

求军哥来看看

[复制链接]
发表于 2013-9-1 19:55:53 | 显示全部楼层 |阅读模式

服务器是centos6.4 x64的版本。安装的是lnmp1.0 mysql版本5.5.28-log
现在导出数据库报错,求军哥看看。。。

这是备份命令

for db in `mysql -u111 -p1111 -B -N -e 'SHOW DATABASES' | xargs`; do
    (mysqldump -u1111 -p1111 ${db} --skip-lock-tables | gzip -9 - > ${db}.sql.gz)
done



报错是这个
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `INNODB_BUFFER_PAGE`': Lost connection to MySQL server during query (2013)
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) when trying to connect
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) when trying to connect
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect

[ 本帖最后由 jalena 于 2013-9-1 20:00 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-9-2 10:09:24 | 显示全部楼层


mysql可能挂掉或没启动
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-9-2 12:34:50 | 显示全部楼层

回复 2# 的帖子


启动了的,现在主要是要写个备份的脚本。总是在导出数据的地方报错,不过现在好了,我把几个默认库给排除了就ok。
  1. #!/bin/bash

  2. # Author: Jalena
  3. # Website: http://jalena.bcsytv.com/archives/1099

  4. # 常规定义
  5. MYSQL_USER="user"
  6. MYSQL_PASS="pass"
  7. DROPBOX_DIR="/backup/$(date +%Y-%m-%d)"
  8. BACK_DIR="backup"

  9. # 备份网站数据目录
  10. NGINX_DATA="/usr/local/nginx/conf/vhost"
  11. BACKUP_BLOG="/home/wwwroot/blog"
  12. BACKUP_DEFAULT="/home/wwwroot/default"
  13. BACKUP_JOOMLA="/home/wwwroot/joomla"

  14. # 定义备份文件名
  15. mysql_DATA=mysql_$(date +"%Y%m%d").tar.gz
  16. www_BLOG=blog_$(date +%Y%m%d).tar.gz
  17. www_DEFAULT=deafult_$(date +%Y%m%d).tar.gz
  18. www_joomla=joomla_$(date +%Y%m%d).tar.gz
  19. nginx_config=nginx_$(date +%Y%m%d).tar.gz

  20. # 定义Dropbox远程文件夹(3天删除一次)
  21. Old_DROPBOX_DIR=/backup/$(date -d -3day +%Y-%m-%d)

  22. # 判断本地备份目录,不存在则创建
  23. if [ ! -d $BACK_DIR ] ;
  24.   then
  25.    mkdir -p "$BACK_DIR"
  26. fi

  27. # 进入备份目录
  28. cd $BACK_DIR

  29. # 备份所有数据库
  30. # 导出需要备份的数据库,清除不需要备份的库
  31. mysql -uroot -pprivacy -B -N -e 'SHOW DATABASES' > databases.db
  32. sed -i '/performance_schema/d' databases.db
  33. sed -i '/information_schema/d' databases.db
  34. sed -i '/mysql/d' databases.db

  35. for db in $(cat databases.db)
  36. do
  37.    mysqldump -u$MYSQL_USER -p$MYSQL_PASS ${db} | gzip -9 - > ${db}.sql.gz
  38. done

  39. # 打包数据库
  40. tar -zcvf $mysql_DATA *.sql.gz

  41. # 打包本地网站数据
  42. tar -zcvf $www_BLOG $BACKUP_BLOG
  43. tar -zcvf $www_DEFAULT $BACKUP_DEFAULT

  44. # 打包Nginx配置文件
  45. tar -zcvf $nginx_config $NGINX_DATA/*.conf

  46. # upload
  47. cd ~
  48. ./dropbox_uploader.sh upload /$BACK_DIR/$mysql_DATA $DROPBOX_DIR/$mysql_DATA
  49. ./dropbox_uploader.sh upload /$BACK_DIR/$www_BLOG $DROPBOX_DIR/$www_BLOG
  50. ./dropbox_uploader.sh upload /$BACK_DIR/$www_DEFAULT $DROPBOX_DIR/$www_DEFAULT
  51. ./dropbox_uploader.sh upload /$BACK_DIR/$nginx_DATA $DROPBOX_DIR/$nginx_DATA

  52. # Delete all local backup
  53. rm -rf $BACK_DIR

  54. # Delete the file 3  days ago
  55. ./dropbox_uploader.sh delete $Old_DROPBOX_DIR/

  56. # DropBox info
  57. ./dropbox_uploader.sh info

  58. exit 0
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-15 22:24 , Processed in 0.025781 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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