What is the my.ini file used for?

my.ini is the initialization file used by MySQL when it loads. It is similar to php.ini for PHP, and can be modified to set common option values for your MySQL installation. Typically this file will be saved in your MySQL install directory, however you should take care not to copy it to other locations because MySQL will look for your initialization file in several different locations and may load those instead.

The initialization file can be used for most of the MySQL applications, and in this tutorial I'm going to look at mysqldump.

First, lets have a look at the section I've created in my.ini for mysqldump.

[mysqldump]
user=my_user_name
password=my_password
comments
databases
skip-quote-names
add-drop-database
add-drop-table
dump-date

Imagine that I didn't have this initialization file set. If I wanted to use mysqldump then I would have to specify the options at the command prompt. I.e.

mysqldump -user=my_user_name -password=my_password -comments -databases ....

However, because I have the options already preloaded I can use mysqldump much easier like so

mysqldump myDataBase > myDataBase_backup.sql

Username, password and all the standard configuration options that I need to use have already been pre-loaded with the initialization file.


Configuration

The parameters that I have specified are suitable for my development. An explanation for the databases and add-drop-database parameters are covered in another tutorial.

There are a lot more configuration options available for mysqldump, and I encourage you to investigate and find what might be suitable for you. Also other information on using mysqldump can be found on the MySQL reference website.

Tags: 

Comments

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.