Home
 

Customer Support

Search for keywords:

Browse by category:

How do I create a .my.cnf MySQL preference file?

A .my.cnf file (the period at the beginning of the filename is mandatory) is a file that contains some preset MySQL preferences for you.

If the file does not exist in your home directory (top level directory) of your account, then you can create one using a plain text editor like pico or vi. If you create or edit this file on your own computer and then upload it to the server, you'll need to use a plain text editor like Notepad or Homesite, not MS Word.

Because this file name begins with a period, some FTP programs may give you trouble seeing it in directory listings. At a shell prompt, you can always see it, if it is there, by typing
ls -la /
A basic .my.cnf file has the following lines. A pound sign '#' before any line means that line should be ignored by the MySQL interpreter.
[client]
user = DBUSERNAME
password = DBPASSWORD
host = DBSERVER

[mysql]
database = DBNAME
Where DBUSERNAME, DBPASSWORD, DBSERVER and
DBNAME should be replaced with your own correct database username, database hostname, database name and database password. You will not have any of these until you create a database through your Control Panel.

With a correctly setup .my.cnf file, you will be able to get a MySQL Monitor prompt by just typing
mysql
at your shell prompt without any of the arguments such as -h, -u, -p, and without having to explicitly type out your database name. The preferences also work with mysqldump and other mysql related shell commands.

User-Contributed Notes

add a note
04-Sep-2003 17:47
If permission to write to the .my.cnf file is denied, it is probably
because the file is set read-only (chmod 400). To change that, get a
shell prompt:

    http://www.modwest.com/help/kb.phtml?cat=7&qid=116

and change permissions on the file to make it writable:

    chmod 600 /.my.cnf

add a note

Related Questions:


How do I import delimited data into MySQL?

How do I change my MySQL password?

How do I import a MySQL dumpfile into my database?

How can I export data in CSV or tab delimited format?

How do I connect to my MySQL database?

Why do i get a query syntax error 1064 from MySQL when the syntax seems correct?

How do I export and move my database tables between servers or copy databases?

I can't connect to local MySQL server through socket 'mysql.sock'

What is my database server name?

How do I change MySQL timezone?

What is my MySQL Username or Database Name?

MySQL says I have too many connections.

How do I check how much disk space my database is using?

A MySQL MYI table has errors in it.

Can I connect to MySQL remotely?

Can I connect to my MySQL database from my own computer?

I can't get phpMyAdmin to work.

phpMyAdmin gives SQL syntax error when I try to create table.

How can I use odbc_connect() in my PHP scripts to connect to MySQL?

What kind of database server do you offer?

How many databases do I get?

What am I allowed to do with my MySQL database?

Will we be able to do our own MySQL admin?

How do I import a MySQL dumpfile into my database via phpMyAdmin?

Do you offer MySQL 5?

How do I export a MySQL dumpfile via phpMyAdmin?

Browse Categories:

Getting Started, FTP, Telnet/SSH, Moving Domains, E-mail, Traffic Reports, Mailing Lists, Apache, PHP, CGI, Other Server-Side Scripting, MySQL Database, Imaging Libraries, Other Software, Billing & Terms, Control Panel, E-commerce, Pre-Sales


Tiny Modwest Logo         Copyright 2000-2008 by Modwest, Inc.          About Us    |    Blog    |    Jobs    |    Web Design    |    Contact Us