[转载]vps下mysql备份、恢复(特别针对lnmp一键安装包环境)

一般小型网站的mysql数据库都是用phpmyadmin备份还原数据库

但是论坛数据有时候变大了,phpmyadmin不是那么给力,譬如说300M的数据库,再用phpmyadmin那就有点那个啥了

直接用SSH登陆备份是最省事的

这里都是针对lnmp一键安装包的默认环境,如果是其他环境,只需要改变下目录名称就可以了

备份数据

/usr/local/mysql/bin/mysqldump -u root -pmima ultrax > /home/wwwroot/my.sql (mysqldump最好使用绝对路径)

其中:root为数据库用户名
mima为对应root数据库密码,密码和-P之间不要有空格
ultrax(是discuz默认新建的)是需要导出的数据库名。
/home/backup/discuz.sql是数据库文件sql导出的路径。

恢复数据

/usr/local/mysql/bin/mysql -u root -pmima xxx< /home/backup/discu.sql

还有一个最直接的办法,那就是直接备份打包/usr/local/mysql/var/ultrax这个目录,xxx是数据库名,还原的时候解压到这个目录,最后在更改文件夹所述用户为mysql,赋权限,命令如下:

#chown -R mysql:mysql xxx(数据库文件夹)

#chmod 660 xxx/*

分享到:

14 条评论

昵称
  1. What i don’t understood is in reality how you’re now not
    really a lot more smartly-preferred than you mmay be right now.
    You are very intelligent. You know therefore significantly when it comes to this subject, made me in my opinion consider it from so many numerous angles.
    Its like women and men aren’t involved until it is something tto accomplish with Woman gaga!

    Your individual stuffs outstanding. At all times maintain it up!

  2. I absolutely love your blog and find a lot of ypur post’s to be exactly what
    I’m looking for. Does one offer guest writers to write content for you?
    I wouldn’t mind creating a post or elaborating on many of thee subjects
    yyou write related tto here. Again, awesome weblog!

  3. When I originally commented I clicked the “Notify me when new comments are added” checkox
    aand now each time a comment is added I get four e-mails with
    the same comment. Is there any way you can remve me from that service?
    Thank you!

  4. I believe this is among the so much vital information for me.
    And i’m satisfied studying your article.

    But wan to statement on some common issues, The
    website style is wonderful, the articcles is actually great :
    D. Good task, cheers

  5. Thiss website was… how do I say it? Relevant!!
    Finally I have founbd something which helped me.
    Cheers!

  6. maltepe escort

    What’s Happening i’m new to this, I stumbled upon this I have flund It positfively useful and it has helped me out loads.I’m hping
    too contribute & aidd different customers like its aided me.

    Great job.

  7. I think the admin of this website is genuinely working hard for his web page,
    since hesre every stff is quality based stuff.

  8. istanbul escort

    oof coursxe like your websaite however you have to check the spelling on several of your posts.
    A number of them are rife with spelling prolems and I tto find it
    very troublesome to telkl the truth however I will definitely come again again.

  9. umraniye escort

    Thanks inn support off shariing such a good idea, ost
    is good, thats why i have read it completely

  10. maltepe escort

    Incredible qquest there. What occurrded after? Take care!

  11. boston car service

    Hi everyone, it’s my first pay a quick vosit
    at this web page, and post is truly fruitful in favor of me, keep up posting these types of articles or reviews.

  12. Howdy! I just wish to give you a big thumbs upp for the great info you have got here
    on tbis post. I’ll bbe coming back too your sitge for
    ore soon.

  13. http://www.14pd.com/

    冒险岛sf一条龙_惊天动地sf一条龙_热血江湖sf一条龙_问道sf一条龙_密传sf一条龙天龙sf一条龙开服07cg.comQQ1325876192

  14. 端游私服一条龙

    乱舞三国ol4.0www.39uc.cn