1. Open a Windows command prompt.
2. Navigate to the directory where the MySQLDump executable is located, typically: “C:\wamp\bin\mysql\mysql8.2.0\bin”.
3. Use the mysqldump.exe command followed by options:
mysqldump.exe -u root -p mydatabase > C:\Backup\host.sql
4. Here, “-u” specifies the username, “-p” prompts for the password, and “mydatabase” is the name of the database. The output is directed to a file named “host.sql” in the “C:\Backup” directory.
5. Enter the password when prompted.
However, entering the password each time isn’t practical, especially for automated backups. To address this:
6. Create a “my.cnf” file at the root of the “C” drive with the following content:
[Mysqldump]
user = user
password = password
7. Replace “user” and “password” with your MySQL username and password.
8. Save this file and position it at the following locations:
C:\WINDOWS\my.cnf
C:\wamp\mysql\my.cnf
9. Ensure proper security permissions for this file, specifying permissions for the WAMP server’s account.
10. Finally, modify the backup command to exclude the “-p” option, as it will directly reference the password from the “my.cnf” file:
cd "C:\wamp\bin\mysql\mysql8.2.0\bin\"
mysqldump.exe -u root mydatabase > C:\Backup\host.sql
11. Now, the backup should run without requiring manual intervention.
To automate this process further, consider adding the date to the filename, saving it as a batch script, and scheduling it as a task for regular backups. For More Support contact: Host.co.in