How to use .my.cnf files for MySQL
Introduction
The .my.cnf file tells the mysql command-line utility how to connect to a MySQL database. It is typically stored in the home directory of the current user. Here's a sample file:
[mysql]
# Set a larger maximum packet size for the client
max_allowed_packet=512M
user=root
password=my_secret!p@sswordIsVerylong#
Notice the plaintext password is in the file. It's a good idea to set read-write privileges only for the user (ie chmod 600). Now the user should be able to simply type mysql at a command-line and the MySQL monitor should automatically connect to the database.
Introduction
The .my.cnf file tells the mysql command-line utility how to connect to a MySQL database. It is typically stored in the home directory of the current user. Here's a sample file:
[mysql]
# Set a larger maximum packet size for the client
max_allowed_packet=512M
user=root
password=my_secret!p@sswordIsVerylong#
Notice the plaintext password is in the file. It's a good idea to set read-write privileges only for the user (ie chmod 600). Now the user should be able to simply type mysql at a command-line and the MySQL monitor should automatically connect to the database.