{"id":722,"date":"2012-01-20T23:07:49","date_gmt":"2012-01-21T09:07:49","guid":{"rendered":"http:\/\/mymonkeydo.com\/?p=722"},"modified":"2012-01-20T23:07:49","modified_gmt":"2012-01-21T09:07:49","slug":"mysqldump-using-password-no-error","status":"publish","type":"post","link":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/","title":{"rendered":"mysqldump – Using password: NO error"},"content":{"rendered":"

Problem<\/h2>\n

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

mysqldump: Got error: 1045: Access denied for user ‘some_user’@’localhost’ (using password: NO) when trying to connect<\/p>\n

 <\/p>\n

Solution<\/h2>\n

No thanks to JustHost of course. \u00a0They 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”.<\/p>\n

On to the solution. \u00a0The 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. \u00a0I’m not sure of the specifics of this so you can read more on configuration files if you need more details. \u00a0The key that clued me into the problem was a comment on this page. \u00a0 He had a similar problem to what I was having. \u00a0In the end my cnf file looked like below, named “mymysql.cnf”:<\/p>\n

 <\/p>\n

[client]\n# The following password will be sent to all standard MySQL clients\npassword=\"thePassword\"<\/pre>\n

 <\/p>\n

And my bash file looked like so:<\/p>\n

#!\/bin\/bash\n\nmysqldump --defaults-file=\/somedir\/mymysql.cnf -u theusername thedbname > \/somedir\/thedbname`date +%d`.sql<\/pre>\n

 <\/p>\n

keywords: access denied using password NO
\nsource:
http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/option-files.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[2,6],"tags":[51],"yoast_head":"\nmysqldump - Using password: NO error - My Monkey Do<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"mysqldump - Using password: NO error - My Monkey Do\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/\" \/>\n<meta property=\"og:site_name\" content=\"My Monkey Do\" \/>\n<meta property=\"article:published_time\" content=\"2012-01-21T09:07:49+00:00\" \/>\n<meta name=\"author\" content=\"Webhead\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Webhead\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/\",\"url\":\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/\",\"name\":\"mysqldump - Using password: NO error - My Monkey Do\",\"isPartOf\":{\"@id\":\"https:\/\/mymonkeydo.com\/#website\"},\"datePublished\":\"2012-01-21T09:07:49+00:00\",\"dateModified\":\"2012-01-21T09:07:49+00:00\",\"author\":{\"@id\":\"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829\"},\"breadcrumb\":{\"@id\":\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mymonkeydo.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"mysqldump – Using password: NO error\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mymonkeydo.com\/#website\",\"url\":\"https:\/\/mymonkeydo.com\/\",\"name\":\"My Monkey Do\",\"description\":\"A Log of Coding Solutions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mymonkeydo.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829\",\"name\":\"Webhead\",\"url\":\"https:\/\/mymonkeydo.com\/author\/corey\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"mysqldump - Using password: NO error - My Monkey Do","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/","og_locale":"en_US","og_type":"article","og_title":"mysqldump - Using password: NO error - My Monkey Do","og_url":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/","og_site_name":"My Monkey Do","article_published_time":"2012-01-21T09:07:49+00:00","author":"Webhead","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Webhead","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/","url":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/","name":"mysqldump - Using password: NO error - My Monkey Do","isPartOf":{"@id":"https:\/\/mymonkeydo.com\/#website"},"datePublished":"2012-01-21T09:07:49+00:00","dateModified":"2012-01-21T09:07:49+00:00","author":{"@id":"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829"},"breadcrumb":{"@id":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mymonkeydo.com\/mysqldump-using-password-no-error\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mymonkeydo.com\/"},{"@type":"ListItem","position":2,"name":"mysqldump – Using password: NO error"}]},{"@type":"WebSite","@id":"https:\/\/mymonkeydo.com\/#website","url":"https:\/\/mymonkeydo.com\/","name":"My Monkey Do","description":"A Log of Coding Solutions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mymonkeydo.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829","name":"Webhead","url":"https:\/\/mymonkeydo.com\/author\/corey\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/posts\/722"}],"collection":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/comments?post=722"}],"version-history":[{"count":0,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"wp:attachment":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}