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

ee7vknir  于 2023-10-15  发布在  Mysql
关注(0)|答案(5)|浏览(181)

如何在MAMP上导出/导入大型数据库?使用PHPMyAdmin并不像它应该的那样工作。

qrjkbowd

qrjkbowd1#

它应该通过如下终端完成。

  • 在终端中,使用以下命令cd /Applications/MAMP/library/bin导航到MAMP的bin文件夹
  • 使用此命令导出文件./mysqldump -u [USERNAME] -p [DATA_BASENAME] > [PATH_TO_FILE]。EG为./mysqldump -u root -p my_database_name > /Applications/MAMP/htdocs/folder_name/exported_db.sql
  • 行应该显示Enter password:。在这里输入MySQL密码。请记住,这些字母不会出现,但它们在那里。

如果需要导入,请使用BigDump,这是一个MySQL转储导入器。

kuuvgm7e

kuuvgm7e2#

打开MAMP!

然后,对于这两个操作,打开终端并键入:

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

然后在密码箱中输入密码(默认值**root**),然后按回车键。

  • 示例:*

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

正在导入(将删除当前数据库)
/Applications/MAMP/library/bin/mysql -u [USERNAME] -p [DATABASE_NAME] < [PATH_TO_SQL_FILE]

然后在密码箱中输入密码(默认值**root**),然后按回车键。

  • 示例:*

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

  • /!\重要警告:* 在执行此命令之前,请确保备份当前数据库,以防在导入之前需要数据库的副本。这将删除您当前的数据库!*
xfyts7mz

xfyts7mz3#

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

q5lcpyga

q5lcpyga4#

我从MAMP转储数据库时遇到了问题。尝试了很多东西,但总是这个错误:错误:2002年:无法通过套接字'/Applications/MAMP/tmp/mysql/mysql.sock'连接到本地MySQL服务器
尝试创建symlink,但它已被创建“ln:/tmp/mysql.sock:文件存在”
我以为问题出在新Mac或新MAMP上。最后,在我的情况下(问题在我身上),解决方案非常简单:只要打开MAMP:)也许它会帮助某人保存一点时间(我花了大约4个小时)

jvlzgdj9

jvlzgdj95#

从MAMP导出数据库
第一步:

Open a new terminal window

第二步:

Navigate to the MAMP install by entering the following line in terminal
cd /applications/MAMP/library/bin
Hit the enter key

第三步:

Write the dump command
./mysqldump -u [USERNAME] -p [DATA_BASENAME] > [PATH_TO_FILE]
Hit the enter key
Example:
./mysqldump -u root -p wp_database > /Applications/MAMP/htdocs/symposium10_wp/wp_db_onezero.sql
Quick tip: to navigate to a folder quickly you can drag the folder into the terminal window and it will write the location of the folder. It was a great day when someone showed me this.

第四步:

This line of text should appear after you hit enter
Enter password:
So guess what, type your password, keep in mind that the letters will not appear, but they are there
Hit the enter key

第五步:

Check the location of where you stored your file, if it is there, SUCCESS
Now you can import the database, which will be outlined next.

将数据库导入MAMP
第一步:

Open a new terminal window
CAREFUL: This will replace all tables in the database you specify!

第二步:

/applications/MAMP/library/bin/mysql -u [USERNAME] -p [DATABASE_NAME] < [PATH_TO_SQL_FILE]
Hit the Enter Key
Example:
/applications/MAMP/library/bin/mysql -u root -p wordpress_db < /Applications/MAMP/htdocs/backupDB.sql
Quick Tip: Don’t forget that you can simply drag the file into the terminal window and it will enter the location of the file for you.

第三步:

You should be prompted with the following line:
Enter password:
Type your password, keep in mind that the letters will not appear, but they are there
Hit the enter key

第四步:

Check if you database was successfully imported
Navigate to phpMyAdmin in a browser
http://localhost:8888/MAMP/

来源:https://nickhardeman.com/308/export-import-large-database-using-mamp-with-terminal/

相关问题