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.
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.
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
Related
I'm new to MySql. I have downloaded and installed MySql 5.6 together with the latest version of Workbench (6.2). Workbench says my configuration file is in
C:\Program Files\MySQL\MySQL Server 5.0\my.ini
This folder does not exist. I have
C:\Program Files\MySQL\MySQL Server 5.6
And inside this folder there is an .ini file called my-default.ini. How can I find the correct .ini file so I can change my variables?
The name and path used by MySQL Workbench by default is taken from a template. There are several templates for various server versions and platforms with typical config file locations. However, they may not always work. On Windows however, with standard installations (which are extremely common), there are only very few variations. The simplest way to have the correct config file stored in the connection settings is by changing the installation type in the System Profile settings for a connection:
The sample config file my-default.ini is just that, an example. The installer should have created a concrete config file in the ProgramData MySQL folder for your server, which is what MySQL Workbench will also use by default.
For someone wants to find the menu answered above,
It can be found when you right click on a connection instance box of your MySQL workbench home and go to edit connection.
I know this question posted 5 years ago, but I had looked for the menu as well and finally find it. I hope I can add a comment but I cannot due to the reputation;)
Say I have installed MySQL workbench on windows 7 without a server, and I'm connecting to a remote server.
How can I set client configuration (like the [client] section in 'my.ini') for the workbench?
Or maybe I get it the wrong way and the client loads the configuration from the server that it connects to?
Update:
Maybe I wasn't clear enough. The configuration I'm trying to set is command lines to run at the beginning of each transaction, such as:
SET autocommit=0;
SET tx_isolation='READ-COMMITTED';
If MySQL server is installed on my machine, then I can add the following lines to the 'my.ini' file in the installation folder:
[client]
init-command="SET autocommit=0; SET tx_isolation='READ-COMMITTED'"
You asked this a long time ago, and so maybe this is no longer relevant to you, but I will include a way of doing this here to benefit others.
In Workbench open your connection properties.
On the Connection Tab, select the Advanced Tab.
In there add the following two options to the Others section (obviously change the readDefaultFile location to the location of your my.ini).
readDefaultFile=C:\Program Files\MySQL\MySQL Server 5.7\my.ini
readDefaultGroup=client
Now opening connections should read the client section from that my.ini as required.
MySQL Workbench doesn't load any server configuration file for its own configuration. It can work on such a config file for a server, however (server section, usually [mysqld] only).
MySQL Workbench's configuration is a manual step you have to do in order to connect to a server (be it local or remote).
I found many links where unix system is using.
Could anybody give some links for windows settings or tell me some quick start?
There are two listening addreses: 127.0.0.1/2 but mysql can connect also on 127.0.0.3 and so on. That is strange.
Thanks
In Windows, MYSQL.EXE can be called to install a windows service. The service then can be started and stopped using SERVICES.MSC or "NET START/STOP servicename". Part of the service-definition is the path to the MY.INI file that your MySQL instance is to use.
Example:
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install instance1 --defaults-file=c:\instance1\my.ini
In your my.ini file, you need to create a [mysqld] section, and for each instance you need to define a different port number (or ip number) to use, and a different datadir.
Example:
[mysqld]
port=3307
datadir=c:\instance1\data
You can, and should, add additional definition here, or maybe use an existing my.ini file as a base to start from. Also, you need to copy a database datadir into that datadir-location, or generate a new empty datadir using whatever method - you'll end up with c:\instance1\data\mysql and the user.frm, user.MYD, user.MYI and so on files in that directories.
Start the instance using NET START instance1 or SERVICES.MSC. Check EVENTVWR.MSC for error messages if that fails.
Talk to the instance using
mysql --port=3307 --host=127.0.0.1
again avoiding the word localhost, as it has special meaning.
It is then possible to use normal Unix replication tutorials to play with replication. Make sure you are using 127.0.0.1 as a hostname ("localhost" is a magic word in the MySQL/C connector and it's derivates), and that you always also specify a proper port number.
Ok. I found out that I need different servers anyway.
Is there any nice command line MySQL client for windows? I mean a single exe that allows connecting and running a sample query. I've googled and only could find big graphical environments like toad or mysql workbench. I need only a simple command line tool, where can I download sth like this?
EDIT: I don't want to install the whole MySQL package on my PC. I know it's inside the mysql package but how do I download only this cmd line client. Because i don't need anything else.
When you go to the MySQL download page, choose the platform "Microsoft Windows". Then download the "Windows (x86, xx-bit), ZIP Archive" (be sure to select the one with size over 140M.
The binaries will be in the "bin" folder.
I understand that this is not just the client binaries, but at least you don't have to install and setup the entire server.
mysql.exe can do just that....
To connect,
mysql -u root -p (press enter)
It should prompt you to enter root password (u = username, p = password)
Then you can use SQL database commands to do pretty much anything....
You can choose only install the client during server install. The website only offers to let you download the full installer (grab whatever version you want from http://www.mysql.com/downloads/mysql/).
In the install wizard, when prompted for installation type (typical, minimal, custom), choose 'Custom'. On the next screen, select to NOT install the server, and proceed with the rest of the install as normal.
When you're done, you should see just the relevant client programs (mysql, mysqldump, etc) in C:\Program Files\MySQL..\bin
Its pretty simple. I saved the mysql community server in my D:\ drive. Hence this is how i did it.
Goto D:\mysql-5.7.18-winx64\bin and in the address bar type cmd and press enter, so command prompt will open. Now if you're using it for the first time type as mysql -u root -ppress enter. Then it will ask for password, again press enter. Thats it you are connected to the mysql server.
Before this make sure wamp or xampp any of the local server is running because i couldn't able to connect to mysql wihthout xampp running.
Happy Coding.
You can also download MySql workbench (31Mo) which includes mysql.exe and mysqldump.exe.
I successfully tested this when i had to run Perl scripts using DBD:MySql module to run SQL statements against a distant MySql db.
You can access mySQL in command line just by typing:
C:\www\mysql\bin> mysql -u root -p
After which you can type sql commands normally such as:
mysql> SHOW DATABASES;
Here, I am assuming you mySQL installation directory is C:\www\mysql.
I have similar requirement where I need a MySQL client but not server (running in a virtual machine and don't want any additional overhead) and for me the easiest thing was to install MySQL community server taking typical installation options but NOT configure the server, so it never starts, never runs. Added C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin to system path environment variable and I'm able to use the MySQL command line client mssql.exe and mysqladmin.exe programs.
If you are looking for tools like the the mysql and mysqldump command line client for Windows for versions around mysql Ver 14.14 Distrib 5.6.13, for Win32 (x86) it seems to be in HOMEDRIVE:\Program Files (x86)\MySQL\MySQL Workbench version
This directory is also not placed in the path by default so you will need to add it to your PATH environment variable before you can easily run it from the command prompt.
Also, there is a mysql utilities console but it does not work for my needs. Below is a list of the capabilities on the mysql utilities console in case it works for you:
Utility Description
---------------- ---------------------------------------------------------
mysqlauditadmin audit log maintenance utility
mysqlauditgrep audit log search utility
mysqldbcompare compare databases for consistency
mysqldbcopy copy databases from one server to another
mysqldbexport export metadata and data from databases
mysqldbimport import metadata and data from files
mysqldiff compare object definitions among objects where the
difference is how db1.obj1 differs from db2.obj2
mysqldiskusage show disk usage for databases
mysqlfailover automatic replication health monitoring and failover
mysqlfrm show CREATE TABLE from .frm files
mysqlindexcheck check for duplicate or redundant indexes
mysqlmetagrep search metadata
mysqlprocgrep search process information
mysqlreplicate establish replication with a master
mysqlrpladmin administration utility for MySQL replication
mysqlrplcheck check replication
mysqlrplshow show slaves attached to a master
mysqlserverclone start another instance of a running server
mysqlserverinfo show server information
mysqluserclone clone a MySQL user account to one or more new users
mysql.exe is included in mysql package. You don't have to install anything additionally.
download the mysql-5.0.23-win32.zip (this is the smallest possible one) from archived versions in mysql.com website
cut and paste the installation in c drive as mysql folder
then install then follow instructions as per this page:
https://cyleft.wordpress.com/2008/07/20/fixing-mysql-service-could-not-start-1067-errors/
For Windows users:
1.Install the full version of MYSQL
2.On the Windows 10 start button click on search and type in MySQL
3. Select the MYSQL Command Line Client 5.5 (I am using version 5.5)
4. go ahead and run your sql queries/
5. to exit type \q or quit
I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)
--Under the startup variable --> General Parameters --> I changed Data directory: from C:/Program Files/MySQL/MySQL Server 5.0/data to D:/....., but after I stopped the service and restarted it, the following error appeared:
Could not re-connect to the MySQL Server.
Server could not be started.
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
Has anyone else had this problem?
Normally it works like this:
shut down MySQL
change the [mysqld] and [mysqld_safe] datadir variable in the MySQL configuration
change the basedir variable in the same section.
move the location over
restart MySQL
If that doesn't work I have no idea. On linux you can try to move the socket to a new location too, but that shouldn't affect windows. Alternatively you can use a symbolic link on *nix what most people do I guess.
In Windows
Navigate to C:\Program Files\MySQL\MySQL Server 5.4\ and locate the my.ini file
Find the SERVER SECTION and go to approx line 76 and modify the datadir line to where you want your MySQL application data to be stored
Now navigate to C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data\ and copy and paste the mysql folder into your new location.
Restart the MySQL Server in Control Panel > Administrative Tools > Service
You also have to manually modify mysql's configuration (usually my.conf)
MySQL Administrator cannot be used for tasks like this. It is merely a tool for looking at MySQL servers, despite its name. Relocating data is described in many MySQL tutorials and in the manual IIRC. But basically it's just moving the data to a new location while the server is shut down and then correcting the paths in the servers config file.
After that you should be able to restart the server and connect MySQL Administrator to it.
Make sure you give the Network Service Full permissions in the security tab of Windows Explorer options. If the server can't read/write etc. to the selected folder the service will either not start or it will attempt a start and shut right down.