database - How to find the mysql data directory from command line in windows -


in linux find mysql installation directory command which mysql. not find in windows. tried echo %path% , resulted many paths along path mysql bin.

i wanted find mysql data directory command line in windows use in batch program. find mysql data directory linux command line. possible? or how can that?

in case, mysql data directory on installation folder i.e. ..mysql\mysql server 5\data might installed on drive however. want returned command line.

you can issue following query command line:

mysql -uuser -p -e 'show variables variable_name "%dir"' 

output (on linux):

+---------------------------+----------------------------+ | variable_name             | value                      | +---------------------------+----------------------------+ | basedir                   | /usr                       | | character_sets_dir        | /usr/share/mysql/charsets/ | | datadir                   | /var/lib/mysql/            | | innodb_data_home_dir      |                            | | innodb_log_group_home_dir | ./                         | | lc_messages_dir           | /usr/share/mysql/          | | plugin_dir                | /usr/lib/mysql/plugin/     | | slave_load_tmpdir         | /tmp                       | | tmpdir                    | /tmp                       | +---------------------------+----------------------------+ 

output (on macos sierra):

+---------------------------+-----------------------------------------------------------+ | variable_name             | value                                                     | +---------------------------+-----------------------------------------------------------+ | basedir                   | /usr/local/mysql-5.7.17-macos10.12-x86_64/                | | character_sets_dir        | /usr/local/mysql-5.7.17-macos10.12-x86_64/share/charsets/ | | datadir                   | /usr/local/mysql/data/                                    | | innodb_data_home_dir      |                                                           | | innodb_log_group_home_dir | ./                                                        | | innodb_tmpdir             |                                                           | | lc_messages_dir           | /usr/local/mysql-5.7.17-macos10.12-x86_64/share/          | | plugin_dir                | /usr/local/mysql/lib/plugin/                              | | slave_load_tmpdir         | /var/folders/zz/zyxvpxvq6csfxvn_n000009800002_/t/         | | tmpdir                    | /var/folders/zz/zyxvpxvq6csfxvn_n000009800002_/t/         | +---------------------------+-----------------------------------------------------------+ 

or if want data dir use:

mysql -uuser -p -e 'show variables variable_name = "datadir"' 

this work on windows well.

btw, when executing which mysql in linux told, you'll not installation directory on linux. you'll binary path, /usr/bin on linux, see mysql installation using multiple folders store files.


if need value of datadir output, , that, without column headers etc, don't have gnu environment (awk|grep|sed ...) use following command line:

mysql -s -n -uuser -p information_schema -e 'select variable_value global_variables variable_name = "datadir"' 

the command select value mysql's internal information_schema database , disables tabular output , column headers.

output on linux:

/var/lib/mysql 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -