mysql : 소스 오류 2?
특정 .sql 파일, 즉 'metropolises.sql'
이전에 데이터베이스에서 만들고 저장 한 파일을 가져 오려고 하면 다음 오류가 표시됩니다.
'metropolises.sql'파일을 열지 못했습니다. 오류 : 2
무엇이 잘못되었는지 아십니까?
당신이 사용하려고하는 것을 의미 가정 명령을 텍스트 파일에서 SQL 문을 실행하기 위해, 오류 번호는 POSIX 층에서 통과 될 것으로 보인다 주어진.source
따라서이 리소스를 사용 하여 오류 값 2가 "해당 파일이나 디렉토리가 없음"을 의미한다고 추론 할 수 있습니다.
요컨대, 경로가 잘못되었습니다.
MySQL 서버의 컨텍스트에서 현재 작업 디렉토리 가 무엇인지 명확하지 않으므로 절대 경로를 제공 하십시오. 셸의 작업 디렉토리라고 가정 할 수 있지만 이것이 사실이라고 예상해야하는 것은 분명하지 않습니다.
그냥 사용 절대 경로 의 파일을하고, 대신 백 슬래시를 사용, 사용 앞으로 슬래시.
예:
와 백 슬래시 : 소스 C : \ 폴더 1 \ metropolises.sql
와 슬래시 : 소스 C : /folder1/metropolises.sql
관련 문제 소스 명령을 실행하는 동안 오류 2가 발생했습니다. 파일 이름이나 파일 경로에 공백이 포함되어 있어도 파일 이름은 따옴표로 묶여서는 안됩니다.
아마도 파일의 파일 경로 일 것입니다. 사용하려는 파일의 정확한 위치를 모르는 경우 Finder에서 파일을 찾은 다음 파일을 터미널 창으로 드래그하십시오.
mysql> SOURCE dragfilePathHere
나는 먼저 파일에 도달
c:\windows>cd c:\akura\Db Scripts
c:\akura\Db Scripts>mysql -u root -p root
mysql>\. EXECUTER_NEW_USER.sql
here EXECUTER_NEW_USER.sql my file name
Windows에서 동일한 오류가 발생했습니다. 나는 (cmd에서 : mysql -u root 이후)로 해결했습니다.
mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;
올바른 파일 경로를 입력했는지 확인하십시오
vagrant를 사용하는 경우 파일이 서버에 있는지 확인한 다음 파일 경로를 사용하십시오. 예를 들어 파일이 공용 폴더에 저장되어 있으면
sql> source /var/www/public/xxx.sql
여기서 xxx는 파일의 이름입니다.
이 쿼리를 사용하여 mysql 명령 줄에서이 오류가 발생했습니다.
source `db.sql`;
작동하도록 위의 내용을 다음과 같이 변경했습니다.
source db.sql;
내 Windows 8.1 및 mysql 5.7.9 MySQL Community Server (GPL) ;
에서 파일 경로 뒤를 제거해야했습니다 .
실패 : 소스 E:/jokoni/db/Banking/createTables.sql;
이 작업 : 소스 E:/jokoni/db/Banking/createTables.sql
(종료 없음 및 경로의 창 백 슬래시 대신 슬래시)
내 Mac에서는 이것이 유일한 해결책입니다.
https://stackoverflow.com/a/45530305/5414448
1 - Download the .sql file and remember it's location.
2 - Open your mysql from command prompt or terminal.
3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)
4 - Now exit out from the mysql command line client
5 - Now try and execute this command =>
mysql -u your_username -p your_database_name < your_sql_file_with_complete_location
example - mysql -u root -p trial < /home/abc/Desktop/trial.sql
here my .sql file is named trial and is present in the desktop, the database is also name trial
6 - You should now have your sql file imported to the corresponding mysql database.
사용하는 파일 이름 또는 경로가 올바르지 않을 수 있습니다.
내 시스템에서 c : \에 abcd.sql 파일을 만들었습니다.
그리고 명령을 사용하고 mysql> source c:\abcd.sql
결과를 얻었습니다.
Debian 8 (Jessie) Linux cd
를 사용하는 경우 'metropolises.sql'
. 실행 mysql
및 실행SOURCE ./metropolises.sql;
기본적으로 상대 경로를 시도하십시오 . 나는 이것을 시도하고 작동합니다.
공식 Docker 이미지 레지스트리 ( https://hub.docker.com/_/mysql/) 와 같은 Dockerized MySQL 컨테이너를 실행하는 경우에도이 문제 가 발생할 수 있습니다 .
For me it was because the file was located on a shared drive and it could not access, for some reason, to that path. I cut the file and put it on my local drive in a path without spaces and it got resolved.
I got the same error when i used the command source and gave the sql file path by drag n dropping it.
Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.
soln:
source /home/xyz/file .sql ;(path and a space before file extension)
For Mac users, you can give the path as,
source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;
*I have assumed that the file you need to source
is in your desktop
and the file name is metropolises.sql
If you type,
source metropolises.sql
then the file will be look in the default location,
/Users/YOUR_USER_NAME/metropolises.sql;
The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.
I had a problem on my Mac because one of the folder (directory) names in the path had a space in the name. BTW, the space was escaped by a \, but that was not understood by mySQL
solution - 1) Make sure you're in the root
folder of your app. eg app/db/schema.sql.
solution - 2) open/reveal the folder on your window and drag&&
drop in the command line next to keywork source
(space) filesource. eg source User/myMAC/app/db/schema.sql
I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.
C:\Users\SubhenduD>cd ../
C:\Users>cd ../
C:\>cd \xampp\mysql\bin
C:\xampp\mysql\bin>mysql -u -root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use balticktravels;
mysql> source balticktravels.sql;
Remove spaces in the folder names of the path, It worked for my mac path.
(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)
참고URL : https://stackoverflow.com/questions/14684063/mysql-source-error-2
'IT박스' 카테고리의 다른 글
PHP의 Structs 데이터 유형? (0) | 2020.11.14 |
---|---|
객체 / 인스턴스 / 변수의 존재를 우아하게 확인하고 파이썬에 존재하는 경우 변수에 동시에 할당하는 방법은 무엇입니까? (0) | 2020.11.14 |
사용자 정의 UserControl을 대화 상자로 어떻게 표시합니까? (0) | 2020.11.14 |
사용자가 Android의 갤러리에서 사진을 찍거나 이미지를 선택할 수 있도록하는 단일 의도 (0) | 2020.11.14 |
Android 기기에 HelloWorld.apk를 설치하지 못했습니다 (null) 오류 (0) | 2020.11.14 |