我有一个相当大的数据库,所以我想用命令提示符导出它,但我不知道如何。

我正在使用WAMP。


当前回答

我已经在D: drive安装了我的wamp服务器,所以你必须从ur命令行到以下路径->(如果你已经在c: drive安装了wamp,那么只需将D:替换为c: here)

D:\>cd wamp
D:\wamp>cd bin
D:\wamp\bin>cd mysql
D:\wamp\bin\mysql>cd mysql5.5.8 (whatever ur verserion will be displayed here use keyboard Tab button and select the currently working mysql version on your server if you have more than one mysql versions)
D:\wamp\bin\mysql\mysql5.5.8>cd bin
D:\wamp\bin\mysql\mysql5.5.8\bin>mysqldump -u root -p password db_name > "d:\backupfile.sql"

这里根是我的phpmyadmin的用户 密码是phpmyadmin的密码,所以如果你没有为root设置任何密码,在那个地方什么都没有, Db_name是数据库(为哪个数据库进行备份) , backupfile。SQL是你想要备份你的数据库的文件,你也可以改变备份文件的位置(d:\backupfile.sql)从任何其他地方在你的计算机

其他回答

您可以使用此脚本从终端导出或导入任何数据库 网址:https://github.com/Ridhwanluthra/mysql_import_export_script/blob/master/mysql_import_export_script.sh

echo -e "Welcome to the import/export database utility\n"
echo -e "the default location of mysqldump file is: /opt/lampp/bin/mysqldump\n"
echo -e "the default location of mysql file is: /opt/lampp/bin/mysql\n"
read -p 'Would like you like to change the default location [y/n]: ' location_change
read -p "Please enter your username: " u_name
read -p 'Would you like to import or export a database: [import/export]: ' action
echo

mysqldump_location=/opt/lampp/bin/mysqldump
mysql_location=/opt/lampp/bin/mysql

if [ "$action" == "export" ]; then
    if [ "$location_change" == "y" ]; then
        read -p 'Give the location of mysqldump that you want to use: ' mysqldump_location
        echo
    else
        echo -e "Using default location of mysqldump\n"
    fi
    read -p 'Give the name of database in which you would like to export: ' db_name
    read -p 'Give the complete path of the .sql file in which you would like to export the database: ' sql_file
    $mysqldump_location -u $u_name -p $db_name > $sql_file
elif [ "$action" == "import" ]; then
    if [ "$location_change" == "y" ]; then
        read -p 'Give the location of mysql that you want to use: ' mysql_location
        echo
    else
        echo -e "Using default location of mysql\n"
    fi
    read -p 'Give the complete path of the .sql file you would like to import: ' sql_file
    read -p 'Give the name of database in which to import this file: ' db_name
    $mysql_location -u $u_name -p $db_name < $sql_file
else
    echo "please select a valid command"
fi

给出这个命令来导出您的数据库,这将包括日期

mysqldump -u[username] -p[userpassword] --databases yourdatabase | gzip > /home/pi/database_backup/database_`date '+%m-%d-%Y'`.sql.gz

(-p后没有空格)

进口:

mysql -u db_username -p newFileName < databasName.sql

出口:

mysqldump -u db_username -p databasName > newFileName.sql
mysqldump --no-tablespaces -u username -p pass database_name > db_backup_file.sql

mysql -u -p databaseName>fileToPutDatabase . mysql