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 wh开发者_如何学编程ere it's saved when I create it?
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.
Usually is here:
/var/lib/mysql
But that depends on your configuration.
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';
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 :
- open terminal
- go to your db directory : cd /var/lib/mysql
- Last , sudo chmod -R 777 /var/lib/mysql
Done.
run this query
select @@datadir;
this will result somthing like this /var/lib/mysql
First you have to enable to show hidden Items (then open ProgramData). The go to "C:\ProgramData\MySQL\MySQL Server 8.0\Data"
for me it was in
/opt/lampp/var/mysql/
精彩评论