MySQL Without The Login Prompt

There may be times when you want to use MySQL without the login prompt like when running cron jobs. For that MySQL has something called Option Files wherein you can specify commonly used options so you do not need to enter them in the command line.

To use MySQL without the login prompt, create a file in your home directory:

touch ~/.my.cnf

Modify the file and paste the following configuration:

[mysql]
user=your_mysql_user
password=your_mysql_password

You may also specify your configuration for mysqldump so that you can backup files with cron periodically :)

[mysqldump]
user=my_user
password=my_password

Comments