1

I come from the oracle world where the tnsnames.ora file contain all the sql connection information.

I cannot seem to find the file containing such information for mysql. Could someone with a windows machine tell me where I can find it please.

Uncle Iroh
  • 5,748
  • 6
  • 48
  • 61
  • MySQL doesn't really have a connections file. You'll usually supply host & credentials at connection-time, but there are some default client options that can [be specified in my.cnf](http://dev.mysql.com/doc/refman/5.1/en/option-files.html) – Michael Berkowski May 12 '14 at 15:56
  • Ok, so I'm using the MySQL workbench...does it have such a configuration file somewhere? – Uncle Iroh May 12 '14 at 15:58
  • 1
    Ah. Don't know about Windows, but on a *nix system Workbench will create `$HOME/.mysql/workbench` in which there's a `connections.xml` file that stores the connections you created in the GUI. – Michael Berkowski May 12 '14 at 16:01
  • Excellent, that is what i needed -- connections.xml found in C:\Users\natha_000\AppData\Roaming\MySQL\Workbench – Uncle Iroh May 12 '14 at 16:04

2 Answers2

3

MySQL doesn't need a connections file analogous to the .tns file. MySQL has nothing like a TNS. Connection parameters typically are configured explicitly in your application.

You can optionally create a file called .my.cnf that contains a user's default parameters for connecting.

See also What is the location of mysql client “.my.cnf” in Windows? that shows how to use mysql --help to find out the location of all the config files.

Most people just configure one set of connection parameters in their .my.cnf file, but you can configure multiple sets of connection parameters under different [client] groups, and invoke MySQL client tools to use the respective connection. There's an excellent blog that describes how to set this up here: http://datacharmer.blogspot.com/2011/03/hidden-options-file-trick.html


Re your updated info:

Sorry, I had to boot up a Windows box and install MySQL Workbench to check where the connection info is stored. I don't normally use Windows.

Right, for MySQL Workbench, the connection data is in for example,
C:\Users\Uncle Iroh\AppData\Roaming\MySQL\Workbench\connections.xml

But you're not expected to edit this by hand, and you'll probably ruin it if you try. It's undocumented, and presumably the format could change if you change versions of MySQL Workbench. You should create or edit connections in the Workbench GUI.

Community
  • 1
  • 1
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
1

There is no such thing in MySQL. Check for a config file called my.ini or my.cnf. If MySQL is using a non-default port (not 3306), it will be detailed there. Otherwise, connect using:

mysql -u user -p 

This is an executable (mysql.exe) you'll find in the bin directory of the installation (probably). For example, on my Windows box it's here: C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysql.exe

dwjv
  • 1,227
  • 9
  • 15