在MySQL中创建数据库时,我的数据库保存在哪里? [英] where is my database saved when I create it in MySQL?

查看:676
本文介绍了在MySQL中创建数据库时,我的数据库保存在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对ubuntu和MySQL完全陌生,我通过以下方式创建了一个新的数据库:

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?

推荐答案

在你的mysql配置文件是mysql保存其数据的位置

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

类似:

datadir = /var/lib/mysql

然后为每个数据库创建一个子目录将存储数据库内容(例如:/ var / lib / mysql / mydatabase)。据我所知,你不能指定一个特定的数据库存储在datadir之外。

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.

这篇关于在MySQL中创建数据库时,我的数据库保存在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆