

) then use the following command line: mysql -s -N -uUSER -p information_schema -e 'SELECT Variable_Value FROM GLOBAL_VARIABLES WHERE Variable_Name = "datadir"' If you need the value of datadir as output, and only that, without column headers etc, but you don't have a GNU environment (awk|grep|sed.

You'll only get the binary path, which is /usr/bin on Linux, but you see the mysql installation is using multiple folders to store files.
#Mysql database file location linux windows#
These commands work on Windows too, but you need to invert the single and double quotes.ītw, when executing which mysql in Linux as you told, you'll not get the installation directory on Linux. Create soft links to the storage of each database being migrated. Or if you want only the data dir use: mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name = "datadir"' | plugin_dir | /usr/local/mysql/lib/plugin/ | | character_sets_dir | /usr/share/mysql/charsets/ | sqlite is a single-file database, in which users just open the file and read and write to it, while mysql is a more traditional relational database system with a server and a client, where the server manages the database (which is generally in a directory of files), while the client just connects to the server. You can't use sqlite on a mysql database. Only then they will continue to work.You can issue the following query from the command line: mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name LIKE "%dir"' sqlite and mysql are two different databases. You will need to copy the existing database files from old to new location. You can change the value of this variable and restart the server to change MySQL database location. It’s value is MySQL database location in Linux/Mac. User = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp language = /usr/share/mysql/english skip-external-lockingģ) Find the “datadir” variable.

$ find / -name my.cnfĢ) View the my.cnf file $ cat /etc/mysql/my.cnf MySQL database location in Linux / Macġ) Locate the my.cnf with the find / -name my.cnf command.

It’s value is the MySQL database location in Windows. All MySQL installations have certain standard databases: The mysql directory corresponds to the mysql system database, which contains information required by the MySQL server as it runs. #Path to the database rootĭatadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data/"įind the “datadir” variable. Each subdirectory of the data directory is a database directory and corresponds to a database managed by the server. You can find MySQL database location on your hard disk in the following ways: MySQL database location in Windowsġ) Locate the my.ini file, which store in the MySQL installation folder.įor Example, C:\Program Files\MySQL\MySQL Server 5.5\my.iniĢ) Open the “my.ini” with notepad.
