Reputation:
I'm completely new to ubuntu and MySQL and I created a new database via:
mysql -u root -p
create database mydb;
Now, in which directory is this database saved and how do I specify where it's saved when I create it?
Upvotes: 11
Views: 29543
Reputation: 154
First you have to enable to show hidden Items (then open ProgramData). The go to "C:\ProgramData\MySQL\MySQL Server 8.0\Data"
Upvotes: 0
Reputation: 170
run this query
select @@datadir;
this will result somthing like this /var/lib/mysql
Upvotes: 0
Reputation: 187
Normally It is here.
/var/lib/mysql
One more thing, it is possible that you don't have permission so you can not copy database and can not take backup.
Follow this step to give permission :
Done.
Upvotes: 0
Reputation: 34308
You shouldn't need to specify where it is saved. That's the point of using mysql. It takes care of all the databasy stuff for you. It comes preconfigured to "just work".
However in the mysql prompt you can use the following commands to look into what is happening and where:
> status
And for example:
> show variables;
> show variables like '%dir%';
..and more specifically datadir
will tell you the exact location:
> show variables like 'datadir';
Upvotes: 4
Reputation: 12037
In your mysql configuration file (usually /etc/mysql/my.cnf) you should have a datadir property, which is the location where mysql will save its data
Something like:
datadir = /var/lib/mysql
It then creates a subdirectory inside that for each database where it will store the database content (ex: /var/lib/mysql/mydatabase). As far as I know, you can't specify one particular database to be stored outside of datadir.
Upvotes: 20
Reputation: 6908
Usually is here:
/var/lib/mysql
But that depends on your configuration.
Upvotes: 5