The command will select the value only from mysql's internal information_schema database and disables the tabular output and column headers. ) 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. 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. 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/ | You can look in /etc/mysql/my.cnf for the configuration file, which should have a datadir option that refers to where the actual data for the database is stored. | character_sets_dir | /usr/share/mysql/charsets/ | Where the mysql database is located my depend on your system, but it's usually in /var/lib/mysql. Is this where it might be?Ĭould someone shed some light on where I might be able to find this file/database? I know it is definitely there because if I try to CREATE it again, I get the message that it can't because it already exists.You can issue the following query from the command line: mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name LIKE "%dir"' The only place I can think of would be what is called the 'root' directory in my computer, but the Ubuntu file manager system won't let me view it because it says I don't have permissions. I tried to find the answer on previous stack overflow posts, and tried the suggestions of: locate sqliteīut unfortunately, none of these showed the file I was looking for. It was at this point that I realized I could not find my database file. However, I then decided I would like to take a look at the tables in the database, so I downloaded an SQLite browser. I created a user and tables in the database using some other code, that doesn't seem relevant here, so I won't bother posting. Then once in mysql, I did the following CREATE DATABASE securities_master I used the following code in the terminal window: $ mysql -u root -p I have created a mysql database using the terminal window in my Ubuntu system (which I am also new to, having been a lifelong windows user). I have done a search on my query and have found similar posts, but I was unable to use the information within them to resolve my problem. Any constructive criticism on how to post better, please just let me know. First ever Stack Overflow post, thanks for your time. Use the -all-databases option to back up all the MySQL databases: mysqldump -u root -p -all-databases > alldatabases.sql Same as with the previous example the command above will create a single dump file containing all the databases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |