Change database files location in MySQL administrator? - mysql

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.

Related

MySQL Workbench Unable to Retrieve Disk Space in Data Dir, Server Stopped

I had mySQL workbench working fine a few weeks ago. Now, any time I log in, I get no connection. Upon inspecting Sever Status, it is showing Stopped. Also, under the Server Directories, it says Unable to Retrieve next to Disk Space in Data Dir.
I also noticed that the configuration file was wrong, or outdated? The Configuration File originally read:
C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
But I looked and there was no MySQL Server 5.5 file in my directory. I do have a MySQL Server 8.0 folder, so I changed the Configuration File to:
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
However, this fails to solve the problem. I've also attempted to run Services from the Start Menu, right click on MYSQL80, and choose start - and it says the service has Started then stopped.
I'm not even sure this missing or mis-directed file is the issue, or whether it's the Unable to Retrieve Disk error (or both are causing the server to fail). I recently changed my login password for my computer - but I doubt that is related to the login credentials for MySQL, right? (I see MYSQL80 properties has password for 'log on' option, but I have no idea what this password even is, or how to change it).
I've also read about this problem online and cannot seem to find an answer that solves the issue. I've tried running MySQL Workbench as an admin too, and that doesn't work either.
Can anyone point me in the right direction? Is there a way to get the server up and running again without a bunch of complicated command line? I appear to have mysqld.exe in the bin file in MySQL 8.0
Thanks all in advance!
In MySql Workbench Server -> Startup/ShutDown -> Start Server.
This Worked for me.
When the my.ini file is messed up I think the best solution is a total uninstall/delete and manual install. Before you do any of the following make sure you go to your current data dir and save your database folders. Then dlete all of your current MySQL related directories and uninstall MySQL and MySQL workbench.
I had this problem when I installed MySQL 8.0.15 with the community installer. The my.ini file that came with the installer did not work correctly after it had been edited. I did a full manual install by downloading that zip folder. I was able to create my own my.ini file containing only the parameters that I was concerned about and it worked.
download zip file from MySQL website
unpack the folder into C:\program files\MySQL\MySQL8.0
within the MySQL8.0 folder that you unpacked the zip folder into, create a text file and save it as my.ini
include the parameters in that my.ini file that you are concerned about. so something like this(just ensure that there is already a folder created for the datadir or else initialization won't work):
[mysqld]
basedire=C:\program files\MySQL\MySQL8.0
datadir=D:\MySQL\Data
....continue with whatever parameters you want to include
initialize the data directory by running these two commands in the command prompt:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --default-file=C:\program files\MySQL\MySQL8.0\my.ini --initialize
install the MySQL server as a service by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --install --default-file=C:\program files\MySQL\MySQL8.0\my.ini
finally, start the server for the first time by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --console

What is the windows path to the MySQL connections file?

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

How can I set client configuration for MySQL Workbench without an installed server?

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).

Mysql service is missing

I have installed Mysql server locally and everything was working Ok but today when I tried to get a connection to the local db, I got an error. After checking services showed that the MySql service is missing.
What is the problem?
I have done it by the following way
Start cmd
Go to the "C:\Program Files\MySQL\MySQL Server 5.6\bin"
type mysqld --install
Like the following image. See for more information.
Go to your mysql bin directory and install mysql service again:
c:
cd \mysql\bin
mysqld-nt.exe --install
or if mysqld-nt.exe is missing (depending on version):
mysqld.exe --install
Then go to services, start the service and set it to automatic start.
I also face the same problem. do the simple steps
Go to bin directory copy the path and set it as a environment variable.
Run the command prompt as admin and cd to bin directory:
Run command : mysqld –install
Now the services are successfully installed
Start the service in service windows of os
Type mysql and go
I came across the same problem. I properly installed the MYSQL Workbench 6.x, but faced the connection as below:
I did a bit R&D on this and found that MySQL service in service.msc is not present. To achieve this I created a new connection in MySQL Workbench then manually configured the MySQL Database Server in "System Profile" (see the below picture).
You also need to install MySQL Database Server and set a configuration file path for my.ini. Now at last test the connection (make sure MySQL service is running in services.msc).
If you wish to have your config file on a different path you have to give your service a name:
mysqld --install NAME --defaults-file=C:\my-opts2.cnf
You can also use the name to install multiple mysql services listening on different sockets if you need that for some reason.
You can see why it's failing by copying the execution path and adding --console to the end in the terminal.
Finally, you can modify the starting path of a service by regediting:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME
That works well but it isn't as useful because the windows service mechanism provides little logging capabilities.
Go to
C:\Program Files\MySQL\MySQL Server 5.2\bin
then Open MySQLInstanceConfig file
then complete the wizard.
Click finish
Solve the problem
I think this is the best way to change the port number also.
It works for me

MySQL and Windows Vista: How to setup replication?

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.