Problem with backing up MySQL database

<!--quoteo(post=150902:date=Oct 3 2005, 01:28 AM:name=TCH-Andy)--><div class='quotetop'>QUOTE(TCH-Andy @ Oct 3 2005, 01:28 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=150902"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Personally, I always use either the backup and restore function, or a short script which does a mysql dump, and then emails my backup every day.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />I seem to be having a problem with my script to do a simple mysql backup. Here is the script:<br /><br />mysqldump -u cpanelusernamename_dbusername -ppassworrd cpanelname_dbname | gzip -c > /home/cpanelname/backups/backup-dbname.sql.gz<br /><br />cpanelusernamename = your login username for cpanel<br />password = your password for the dabase (note, there is NO space between -p and password)<br />dbname = the name of your database<br /><br />The error I am getting is:<br />mysqldump: Got error: 1045: Access denied for user: 'cpanelusernamename_dbusername@localhost' (Using password: YES) when trying to connect<br /><br />Also, I would like to do a simple backup of a directory. What would the the script to do that? Thanks.<!--content-->
<!--quoteo(post=152013:date=Oct 12 2005, 09:56 AM:name=edward19283)--><div class='quotetop'>QUOTE(edward19283 @ Oct 12 2005, 09:56 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=152013"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->The error I am getting is:<br />mysqldump: Got error: 1045: Access denied for user: 'cpanelusernamename_dbusername@localhost' (Using password: YES) when trying to connect<!--QuoteEnd--></div><!--QuoteEEnd--><br />That error can be caused by a number of things: 1) the database username is not correct, 2) the database password is not correct, 3) the database user has not been properly added to the database (granting the database user permission to access the database).<br /><br />I don't know if this is relevant, but you have 'cpanelusernamename_dbusername' for the database username and 'cpanelname_dbname' for the database name. These should be both be prefixed with the same thing - your CPanel username and an underscore ('cpanelname_').<br /><br /><!--quoteo(post=152013:date=Oct 12 2005, 09:56 AM:name=edward19283)--><div class='quotetop'>QUOTE(edward19283 @ Oct 12 2005, 09:56 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=152013"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Also, I would like to do a simple backup of a directory. What would the the script to do that? Thanks.<!--QuoteEnd--></div><!--QuoteEEnd--><br />You might try looking at sites such as hotscripts.com for something like that.<!--content-->
I checked usernames and passwords and made sure I was using my cpanel username where appropriate and still got the same problem. I created a new dbusername and password and added it to the database with all priviledges and created a new cron with this information and I got the same response, copied below, except it now says it is not using the password. <br /><br />Enter password: mysqldump: Got error: 1045: Access denied for user: 'cpanelusername_dbusername@localhost' (Using password: NO) when trying to connect<br /><br />I looked around hotscripts.com, per your suggestion and found another script for mysql backups (automysqlbackup). I decided to try it and configured it to run through cron and it appears to be having the same problem, "Access denied for user". Its error message is copied below: <br /><br />mysqldump: Got error: 1044: Access denied for user: '@localhost' to database 'dbname1' when selecting the database<br />/home/cpanelusername/automysqlbackup.sh.2.2: line 572: /bin/mail: Permission denied<br /><br />Any suggestions? Thanks.<!--content-->
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Also, I would like to do a simple backup of a directory. What would the the script to do that? Thanks.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />I found instructions on using tar to backup the directory, located here: <a href="http://www.tldp.org/LDP/lame/LAME/linux-admin-made-easy/server-backup.html" target="_blank">http://www.tldp.org/LDP/lame/LAME/linux-ad...ver-backup.html</a><br /><br />It seems to be working fine for me.<!--content-->
I submitted a trouble ticket with TCH and there was a syntax error in my cron job. Here is the cron that is working for me:<br /><br />mysqldump -u cpanelusername_dbname --password='password' cpanelusername_dbname | gzip -c > /home/cpanelusername/path<!--content-->
Hey, glad it's working for you! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /><!--content-->
 
Back
Top