명령 프롬프트를 사용하여 mysql 데이터베이스를 내보내려면 어떻게 해야 합니까?
데이터베이스가 매우 크기 때문에 명령 프롬프트를 사용하여 내보내고 싶지만 방법을 모르겠습니다.
WAMP를 사용하고 있습니다.
먼저 명령줄에서 mysql 명령어가 인식되는지 확인합니다.명령어로 이동하지 않으면 다음과 같이 입력합니다.
set path=c:\wamp\bin\mysql\mysql5.1.36\bin
다음 명령을 사용하여 데이터베이스를 내보냅니다.
mysqldump -u YourUser -p YourDatabaseName > wantedsqlfile.sql
데이터베이스 비밀번호를 입력하라는 메시지가 나타납니다.
이 명령어를 실행하는 동안 현재 경로로 데이터베이스를 내보냅니다.
주의: 다음은 Import와 Export에 관한 상세 절차입니다.
다음 명령을 사용합니다.
내보내기:
mysqldump -u [user] -p [db_name] | gzip > [filename_to_compress.sql.gz]
Import의 경우:
gunzip < [compressed_filename.sql.gz] | mysql -u [user] -p[password] [databasename]
주의: 키워드 '-p'와 비밀번호 사이에는 공백이 없습니다.
다음 명령을 사용할 수 있습니다.
mysqldump --databases --user=root --password your_db_name > export_into_db.sql
생성된 파일은 이 명령을 실행한 디렉토리에서 사용할 수 있습니다.
은 공식 하실 수 있습니다.mysqldump: MySQL DB 가져오기
주의: 사용--databases--database마지막 것은 더 이상 지원되지 않기 때문입니다.
즐기세요 :)
먼저 명령 프롬프트를 연 다음 cmd 단위의 bin 디렉토리를 엽니다(cmd 명령으로 알고 계실 것입니다). WAMP 프로그램 파일에 있는 MySql 폴더의 bin 디렉토리로 이동합니다.
run 명령어
mysqldump -u db_username -p database_name > path_where_to_save_sql_file
Enter 키를 누르면 특정 데이터베이스가 내보내지고 지정된 위치로 sql 파일이 생성됩니다.
이해하셨기를 바랍니다:) 질문이 있으시면 알려주세요.
이 경로에서 명령 프롬프트로 이동합니다.
C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin>
그런 다음 이 명령을 실행하여 데이터베이스를 내보냅니다(-p 뒤에 공백 없음).
mysqldump -u[username] -p[userpassword] yourdatabase > [filepath]wantedsqlfile.sql
mysql 인스턴스를 찾습니다.
which mysql
올바른 경우 다음과 같이 내보냅니다(bin의 mamp 폴더에 있는 mysql 인스턴스로 이동합니다).
mysqldump -u [username] -p [password] [dbname] > filename.sql
Sametime에서 압축하려면 다음 절차를 따릅니다.
mysqldump -u [username] -p [password] [db] | gzip > filename.sql.gz
다음으로 이 파일을 서버 간에 이동할 수 있습니다.
scp user@xxx.xxx.xxx.xxx:/path_to_your_dump/filename.sql.gz your_detination_path/
(여기서 xxx.xxx.xxx 를 참조해 주세요.xxx는 서버의 IP 주소입니다.)
다음으로 Import합니다.
gunzip filename.sql.gz | mysql -u [user] -p [password] [database]
및 , 「」, 「」를 합니다.--routines★★★★★★★★★★★★★★★★★★:
mysqldump -u YourUser -p YourDatabaseName --routines > wantedsqlfile.sql
해결책의 (「」를 )> character character)의이 있는 stdout에서 입니다.
문자 인코딩 문제가 있는 경우.예를 들어 다음과 같습니다.
ERROR 1064(42000):SQL 구문에 오류가 있습니다. MySQL 서버 버전에 해당하는 설명서에서 ... 근처에서 사용할 올바른 구문을 확인하십시오.
그럼, 당신은 반드시-r옵션에서 파일을 쓸 수 있습니다.
MySQL
mysqldump -u user -pyour-password-without-space-between-letter-p-and-your-password --default-character-set=utf8 --host $HOST database-name -r dump.sql
도커 사용
docker exec --rm -v $pwd:dump -it mysql:5:7 mysqldump -u user -pyour-password-without-space-between-letter-p-and-your-password --default-character-set=utf8 --host $HOST database-name -r dump/dump.sql
주의: 현재 경로를 인스턴스 내에 덤프로 마운트합니다.
우리는 여기서 답을 찾았다.
반대로 사용하지 마십시오.<덤프를 데이터베이스로 Import할 경우에도 utf8 이외의 문자가 전달되지 않을 수 있지만 source 옵션을 선호합니다.
mysql -u user -pYourPasswordYouNowKnowHow --default-character-set=utf8 your-database
mysql> SET names 'utf8'
mysql> SOURCE dump.sql
데이터베이스를 내보내려면 이 명령을 지정하십시오. 여기에는 날짜도 포함됩니다.
mysqldump -u[username] -p[userpassword] --databases yourdatabase | gzip > /home/pi/database_backup/database_`date '+%m-%d-%Y'`.sql.gz
(-p 뒤에 공백 없음)
WAMP 서버를 D:드라이브에 설치했으므로 명령줄에서 다음 경로로 이동해야 합니다.-> (또한 c:드라이브에 ur wamp를 설치한 경우에는 d:wtih c:여기서만 교환해 주세요)
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"
여기서 root은 my phpmyadmin 비밀번호입니다.따라서 root no 타입에 대한 비밀번호를 설정하지 않은 경우 db_name은 데이터베이스(백업을 수행하는 데이터베이스), backupfile입니다.sql은 데이터베이스의 백업을 필요로 하는 파일입니다.또한 백업파일 위치(d:\backupfile.sql)를 에서 컴퓨터상의 다른 곳으로 변경할 수도 있습니다.
mysqldump -h [host] -p -u [user] [database name] > filename.sql
localhost의 예
mysqldump -h localhost -p -u root cookbook > cookbook.sql
mysqldump --no-tablespaces -u username -p pass database_name > db_backup_file.sql
구문
(mysqldump.exe full path) -u (user name) -p (password) (database name) > (export database file full path)
예
c:>d:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe -u root -p mydbname > d:\mydb.sql
여기서 d:\wamp\bin\mysqldump를 지정합니다.exe는 실제 mysqldump.exe 경로가 됩니다.mydbname은 내보낼 데이터베이스의 이름이고 d:\mydb.sql은 내보낸 데이터베이스를 저장하는 경로입니다.
WAMP 서버를 사용한 적이 있습니다.입어봤어요
c:\wamp\bin\mysql\mysql5.5.8\bin\mysqldump -uroot -p db_name > c:\somefolder\filename.sql
root는 mysql의 사용자 이름입니다.패스워드가 있는 경우는, 다음과 같이 지정합니다.
-p[yourpassword]
효과가 있길 바래.
Windows OS의 경우:
mysqldump 명령어 실행 중 오류 1064 mysql(42000)이 표시되면 현재 단말기를 종료합니다.mysqldump 명령을 실행합니다.
mysql>exit
c:\xampp\mysql\bin>mysqldump -uroot -p --databases [database_name] > name_for_export_db.sql
도커에서 실행되고 있는 db의 덤프를 가져오려고 했는데, 같은 작업을 수행하기 위해 다음 명령을 생각해 냈습니다.
도커 이그제큐티브<container_id/name>/usr/bin/mysqldump -u<db_username>--패스워드=<db_password> db_name> . sql
이게 도움이 됐으면 좋겠네요!
mysql - u - p database Name > file ToPut Database
다음 스크립트를 사용하여 다음 링크에서 지정된 단말기에서 데이터베이스를 내보내거나 가져올 수 있습니다.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
언급URL : https://stackoverflow.com/questions/3031412/how-to-export-a-mysql-database-using-command-prompt
'programing' 카테고리의 다른 글
| django 테스트에서는 mariadb와 keepdb를 어떻게 사용합니까? (0) | 2023.02.05 |
|---|---|
| Spring MVC 또는 Spring-Boot에서 다양한 유형의 ResponseEntity를 반환하는 가장 좋은 방법은 무엇입니까? (0) | 2023.02.05 |
| CREATE TABLE 문에 생성되지 않은 인덱스 및 제약 조건 (0) | 2023.02.05 |
| 스프링 데이터 JPA에서 FetchMode의 작동 방식 (0) | 2023.01.26 |
| node.install 서버의 모든 인스턴스를 중지합니다. (0) | 2023.01.26 |