Home >Database >Mysql Tutorial >How to Perform a Passwordless `mysqldump` in Ubuntu?

How to Perform a Passwordless `mysqldump` in Ubuntu?

Barbara Streisand
Barbara StreisandOriginal
2024-12-07 11:39:14260browse

How to Perform a Passwordless `mysqldump` in Ubuntu?

Performing Mysqldump Without Password Prompt

Automated database backups through cron jobs often encounter password input issues. This article presents effective methods to resolve this challenge in Ubuntu without password prompts.

Solution 1: Create a Configuration File

  1. Open a terminal and navigate to your home directory.
  2. Create a file named ~/.my.cnf with permissions set to 600.
  3. Add the following content to the file:
[mysqldump]
user=mysqluser
password=secret

This configuration file stores your MySQL username and password, eliminating the need for manual input.

Solution 2: Command Line Options

Alternatively, you can use the following command line option:

mysqldump -u [user name] -p[password] [database name] > [dump file]

However, note that this method stores the password within the command, making it insecure and accessible to other users.

The above is the detailed content of How to Perform a Passwordless `mysqldump` in Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn