For SQLite, the program directly put the database information - schema/data into a file.
In command line prompt, it's
% sqllite3
So How about for MySQL database? Even for a local usage, I need to set up a client-server login to access the database. Anyway, the data has to be put somewhere on the disk to take some space.
More specifically, how to configure the MySQL data storage location? If I need to move the MySQL data to another directory or disk partition, how to proceed?
Change the datadir value in my.cnf file of your MySQL installation
If you are in Windows, probably you will find this file in C:\Program Files\MySQL\MySQL Server 5.1\my.ini or where ever drive your MySQL installation in
If you are in Linux, probably you will find the file in /etc/mysql/my.cnf
You could check here for more info
Related
I have a dead hard drive. I've connected it with SATA to USB IDE and can recover files. Also the filesystems looks good. How Can I get a dump of database from that hard drive. The laptop I'm using also has mysql installed in it. I'm using xampp. I've tried the following command.
G:/xampp/mysql/bin/mysqldump -u root -p uma > D:/umaoldbackup.sql
This is not giving dump of a latest data. And I think it's giving dump from my local computer.
Please help.
Correct, mysqldump connects to the running MySQL Server process on your local computer, not the data on your sick hard drive.
MySQL client applications like mysqldump do not read the data files directly. They connect to a MySQL Server process and make requests for the data. Before you can access that data, you need to restore the data files to the data directory of an instance of MySQL Server.
Stop the MySQL service.
Copy data files to the data directory of your MySQL service. Move any existing data files to someplace else that is safe, if you want to bring back that data after exporting your umaoldbackup.
Start the MySQL service so it can read the files in that data directory.
You should probably get someone to do this for you if you don't know how to start and stop services on Windows.
Re your comment about where is the data directory...
I'm not a user of Windows or XAMPP.
It's probably actually C:\xampp\mysql\data according to What is the exact location of Mysql database tables in XAMPP folder?
But you can confirm that by connecting to your current MySQL service with a client and running the following query:
SELECT ##datadir;
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
I have a hard disk that MySQL 5 has been installed on it (this hard disk belongs to another PC with Windows XP) and I've connected it to my PC. How can i copy its MySQL data to another MySQL 5 ??
thanks in advance.
you can try this.
Shut down both mysql server.
Locate the mysql data directory (e.g. /. If your database use myisam as engine you will find for any database a folder. In this folder are the files for each table, indexfiles and datafiles. Copy the folder to the data directory on your pc.
Start your mysql server.
PS: Check the version of both servers.
Or you can use mysqldump this is an command line utility for mysql. After export copy the export file to your server and use this command:
mysql -u<username> -p<password> < <exportfilename>
Kind Regards
Okay, heres a easy one for all you mysql folks out there:
Our Win 2003 server crashed last night (durring installing of windows updates). We were able to restore old data from backup, but we miss 22 hours of data. We cannot start windows and therefore not access the data through mySql admin which is the program I use normally to make backup. We have however been able to copy all data to external harddisk.
How do I access these data usning MySql Query browser and MySql Administrator tool?
If you don't have binlogs enabled, or cannot be sure at which point your backup snapshot was made trying to get the datadir running in another server is about your only option. (Which for maximum possibility of recovery should be as much like the original as possible in MySQL version and other environmental data).
If you do have active binlogs, look at this manual
Please let me preface this by saying, I'm not a Windows administrator, so permissions issues are outside my expertise.
Setup a new machine running the same version of MySQL.
Create a new folder and copy your backup of mysql data to that folder, including the mysql database.
Edit your my.cnf file on the new machine to change the following:
# set your data directory
datadir = c:\path\to\new\datadir
# just in case
skip-slave-start
# optional
skip-networking
# if this is an emergency and you need to go through password recovery
skip-grant-tables
Restart MySQL and watch your error log for output. It should start up and you can simply sign in as 'root' with no password and do what you need to do to backup your data.
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.