我把 mysql 恢复文件放在哪里?

发布于 2024-10-09 12:52:58 字数 263 浏览 0 评论 0原文

我正在尝试将 mysql 数据库从具有 phpMyAdmin 的服务器迁移到不具有 phpMyAdmin 的服务器。我有一个从 phpMyAdmin 服务器导出的 .sql 文件,但不太确定从那里去哪里。在寻找答案时,我不断寻找说使用此命令的网站:

mysql -u USER -p DBNAME < dump.sql

但没有任何地方描述该文件应位于何处。它应该位于 var/lib/mysql 目录中吗?

感谢您的帮助。

I'm trying to migrate a mysql database from a server with phpMyAdmin to one that doesn't. I have a .sql file exported from the phpMyAdmin server, and am not quite sure where to go from there. While searching for an answer, I keep on finding websites that say to use this command:

mysql -u USER -p DBNAME < dump.sql

but nowhere describes WHERE that file should be located. Is it just supposed to be in the var/lib/mysql directory?

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜扑 2024-10-16 12:52:58

它可以在任何地方。如果不在当前目录中,则使用完整路径

mysql -u USER -p DBNAME

/home/dump.sql

(如果文件位于 /home/ 文件夹中)

It can be anywhere. Use full path if not in the current directory

mysql -u USER -p DBNAME <
/home/dump.sql

(if the file is in /home/ folder)

北笙凉宸 2024-10-16 12:52:58

编辑:感谢您的更正,TehShrike。

您可以在 -p 后跟用户 USER 的密码 - 在这种情况下,选项 p 和密码之间没有空格。否则,mysql会提示你输入密码。因此语法如下:

mysql -u <user> -p<password> <database-name> < <path-to-mysqldump-file>

如果数据库尚不存在,则必须登录 mysql 服务器并首先创建它(在上面的行之前):

mysql -u <user> -p <password> 
create database <database-name>

EDIT: Thanks for the correction, TehShrike.

You may follow -p with the password for user USER -- in which case there is no space between the option p and the password. Otherwise, mysql will prompt you for password. So the syntax is like the following:

mysql -u <user> -p<password> <database-name> < <path-to-mysqldump-file>

If the database does not already exist, you will have to login to your mysql server and create it first (Before the above line):

mysql -u <user> -p <password> 
create database <database-name>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文