简体   繁体   English

如何在 MAMP 上导出/导入大型数据库

[英]How To Export/Import Large Database On MAMP

How do I export/import large database on MAMP ?如何在 MAMP 上导出/导入大型数据库? Using PHPMyAdmin does not work as it supposed to be.使用 PHPMyAdmin 无法正常工作。

It should be done via terminal as below.它应该通过终端完成,如下所示。

  • In the terminal navigate to bin folder of MAMP using below command cd /Applications/MAMP/library/bin在终端中使用以下命令导航到 MAMP 的bin文件夹cd /Applications/MAMP/library/bin
  • Use this command to export the file ./mysqldump -u [USERNAME] -p [DATA_BASENAME] > [PATH_TO_FILE] .使用此命令导出文件./mysqldump -u [USERNAME] -p [DATA_BASENAME] > [PATH_TO_FILE] EG would be ./mysqldump -u root -p my_database_name > /Applications/MAMP/htdocs/folder_name/exported_db.sql EG 将是./mysqldump -u root -p my_database_name > /Applications/MAMP/htdocs/folder_name/exported_db.sql
  • Line should appear saying Enter password: .应该出现一行Enter password: Here enter the MySQL password.在这里输入 MySQL 密码。 keep in mind that the letters will not appear, but they are there.请记住,这些字母不会出现,但它们就在那里。

If you need to import use BigDump Which is a MySQL Dump Importer.如果您需要导入使用BigDump ,它是一个 MySQL Dump Importer。

Turn on MAMP!打开 MAMP!

Then, for both operations, open the terminal and type:然后,对于这两个操作,打开终端并输入:


EXPORTING:出口:

/Applications/MAMP/library/bin/mysqldump -u [USERNAME] -p [DATABASE_NAME] > [PATH_TO_SQL_FILE]

Then type your password in prompter (default root ) and press enter.然后在提示器中输入您的密码(默认root )并按回车键。

Example:例子:

/Applications/MAMP/library/bin/mysqldump -u root -p my_database_name > /Applications/MAMP/htdocs/folder_name/exported_db.sql


IMPORTING (will erase current database) : IMPORTING (将删除当前数据库)

/Applications/MAMP/library/bin/mysql -u [USERNAME] -p [DATABASE_NAME] < [PATH_TO_SQL_FILE]

Then type your password in prompter (default root ) and press enter.然后在提示器中输入您的密码(默认root )并按回车键。

Example:例子:

/Applications/MAMP/library/bin/mysql -u root -p my_database_name < /Applications/MAMP/htdocs/folder_name/exported_db.sql

/!\ Important Warning: Make sure to backup your current database before doing this command in case you need a copy of it before importing. /!\ 重要警告:确保在执行此命令之前备份当前数据库,以防在导入之前需要它的副本。 This will erase your current database!这将清除您当前的数据库!

如果您使用 MAMP PRO 版本来绕过 phpMyAdmin 为您提供的默认设置,您也可以使用 Sequel Pro 应用程序。

I had a problem to dump my db from MAMP.我从 MAMP 转储我的数据库时遇到问题。 Tried a lot of things, but always this error: Got error: 2002: Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock'尝试了很多东西,但总是出现这个错误: Got error: 2002: Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock'

Tried to create a symlink , but it was already created "ln: /tmp/mysql.sock: File exists"试图创建一个符号链接,但它已经创建了“ln:/tmp/mysql.sock:文件存在”

Thought the problem was new Mac or new MAMP.以为问题出在新 Mac 或新 MAMP 上。 Finally in my case (problem was in me) solution was really simple: just turn on MAMP :) Maybe it will help someone to save a little bit time (I spent around 4 hours)最后在我的情况下(问题在我身上)解决方案非常简单:只需打开 MAMP :) 也许它会帮助某人节省一点时间(我花了大约 4 个小时)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM