Andrew Fletcher published: 16 June 2021 1 minute read
The generally accepted answer to a mysqldump is:
mysqldump -h [host] -u [user] -p [database_name] [table_name] > [file].sql
Or a variant there of... Of course if you are logged in to the server and working from it you don't need to express the -h [host]
mysqldump -u [user] -p [database_name] [table_name] > [file].sql
But no not for me. I wasn't seeing the success story of a downloaded database file. Instead I was warmly embraced by error land:
mysqldump: Got error: 1045: "Access denied for user '[username]'@'localhost' (using password: NO)" when trying to connect
After a quick play around with the username I wanted to log in as and also trying root... the 1045 error kept coming up.
In my situation, the solution was to add sudo at the front of the command. Therefore becoming
sudo mysqldump -u [user] -p [database_name] > [file].sql
Next you will be prompted for the corresponding password, and you are done.
Related articles
Andrew Fletcher
•
16 Jan 2025
get IP address from terminal OSX
When troubleshooting network issues or configuring devices, knowing your IP address can be essential. Whether you're connected via Wi-Fi, Ethernet, or tethering through a mobile provider, macOS offers powerful built-in tools to quickly identify your IP address. Here's a practical guide tailored to...
Andrew Fletcher
•
07 Jan 2025
Managing DDEV environment troubleshooting and setting up multiple Drupal projects
DDEV has become a popular tool for local web development, offering a streamlined approach to managing Docker-based environments. However, setting up and managing DDEV projects, particularly with the latest versions of Docker Desktop, can present challenges. This article guides you through resolving...
Andrew Fletcher
•
28 Dec 2024
Optimising file transfers by improving efficiency from cp to rsync
Transferring files between development and production environments is a critical task in the deployment process. However, I continue to come across multiple approaches that scale from awesome automation using pipelines to the basic of direct command line entry. Where the basic approaches rely on...