Jump to content

Recommended Posts

Posted
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.

 

I seem to be having a problem with my script to do a simple mysql backup. Here is the script:

 

mysqldump -u cpanelusernamename_dbusername -ppassworrd cpanelname_dbname | gzip -c > /home/cpanelname/backups/backup-dbname.sql.gz

 

cpanelusernamename = your login username for cpanel

password = your password for the dabase (note, there is NO space between -p and password)

dbname = the name of your database

 

The error I am getting is:

mysqldump: Got error: 1045: Access denied for user: 'cpanelusernamename_dbusername@localhost' (Using password: YES) when trying to connect

 

Also, I would like to do a simple backup of a directory. What would the the script to do that? Thanks.

Posted
The error I am getting is:

mysqldump: Got error: 1045: Access denied for user: 'cpanelusernamename_dbusername@localhost' (Using password: YES) when trying to connect

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).

 

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_').

 

Also, I would like to do a simple backup of a directory. What would the the script to do that? Thanks.

You might try looking at sites such as hotscripts.com for something like that.

Posted

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.

 

Enter password: mysqldump: Got error: 1045: Access denied for user: 'cpanelusername_dbusername@localhost' (Using password: NO) when trying to connect

 

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:

 

mysqldump: Got error: 1044: Access denied for user: '@localhost' to database 'dbname1' when selecting the database

/home/cpanelusername/automysqlbackup.sh.2.2: line 572: /bin/mail: Permission denied

 

Any suggestions? Thanks.

Posted

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:

 

mysqldump -u cpanelusername_dbname --password='password' cpanelusername_dbname | gzip -c > /home/cpanelusername/path

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...