• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

mysqldump – Using password: NO error

January 20, 2012 by Webhead

Problem

I need to back up a mysql database on a shared hosting server.  I am using the cron job to run a bash file which runs a mysqlcommand.  The problem is that I can’t get MySQL to recognize the password.  I have no spaces after the “-p” however, I still get the following error:

mysqldump: Got error: 1045: Access denied for user ‘some_user’@’localhost’ (using password: NO) when trying to connect

 

Solution

No thanks to JustHost of course.  They don’t know why this doesn’t work as one support member tried to help me, but stopped replying after all his solutions failed and another support member just plain said “we do not provide support for this issue”.

On to the solution.  The problem is that the mysql configuration file on JustHost is set to not supply a password no matter what you pass into the mysqldump command.  I’m not sure of the specifics of this so you can read more on configuration files if you need more details.  The key that clued me into the problem was a comment on this page.   He had a similar problem to what I was having.  In the end my cnf file looked like below, named “mymysql.cnf”:

 

[client]
# The following password will be sent to all standard MySQL clients
password="thePassword"

 

And my bash file looked like so:

#!/bin/bash

mysqldump --defaults-file=/somedir/mymysql.cnf -u theusername thedbname > /somedir/thedbname`date +%d`.sql

 

keywords: access denied using password NO
source: http://dev.mysql.com/doc/refman/5.1/en/option-files.html

Filed Under: Coding, Server Stuff Tagged With: mysql

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization mac os x ms sql mysql open source optimize php php 5.3 responsive rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools