일단 나는 Mac m1 사용자고 homebrew로 mysql을 설치했다.

 

문제상황

MySQL 실행중, 외부에서 csv 파일을 가져와 테이블에 insert하려고 할 때 아래 코드를 실행 시켰더니 에러가 발생했다.

load data infile '/Users/home/Team.csv'
into table Team
fields terminated by ';'
enclosed by ''
lines terminated by 'n'
ignore 1 rows;

 

에러문: ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement 

 

 

원인

M1 터미널에 MySQL을 설치한 뒤 아래 명령어를 사용해서 서버 관련 설정을 해주게 되는데,

$ mysql.server start

 

이때 --secure-file-priv 옵션을 설정해줘서 그렇다고 한다. 위 명령어를 터미널에 입력해 서버를 다시 시작하고, 옵션 설정을 다시 해주면 된다.

 

해결을 시도했으나 실패

서버 설정을 다시 해주려고 위의 명령어를 입력했지만 갑자기 아래와 같은 에러가 떴다. 

 

여기를 참고해서  다음 명령어를 시도했다.

// MySQL에 대한 소유 변경
$ sudo chown -R _mysql:_mysql /opt/homebrew/var/mysql
// MySQL 설치 위치 확인
$ brew --prefix mysql
// MySQL 및 폴더 권한 변경
$ sudo chmod -R 750 /opt/homebrew/opt/mysql
$ sudo chmod -R 750 /opt/homebrew/opt/

 

그러나......

 

해결 안돼서 그냥 여기를 참고해서 mysql을 삭제하고 재설치했다.

 

---

아무튼 다시 본론으로 돌아와서

 

해결 시도 1) infile 앞에 local을 붙여라

load data infile '/Users/yujimin/C:C++/Team.csv'
into table Team
fields terminated by ','
enclosed by ''
lines terminated by 'n'
ignore 1 rows;

 

응안돼~

 

해결 시도 2) my.cnf 파일에 "" 추가

아래 명령어로 my.cnf의 위치를 찾는다.

 

 

/opt/homebrew/etc/my.cnf

 

$ brew sercives restart mysql

 

 

 

???아또왜

 

에러 메시지

. ERROR! The server quit without updating PID file (/opt/homebrew/var/mysql/dhcp198.merusouth113.iit.edu.pid).

 

해결방법

$ sudo rm -rf /opt/homebrew/var/mysql/

$ brew reinstall mysql

$ mysql.server start

$ mysql_secure_installation 

Would you like to setup VALIDATE PASSWORD component? -> n

Remove anonymous users? -> y

Disallow root login remotely? -> n

Remove test database and access to it? -> n

Reload privilege tables now? -> n

 

All done!

 

mysql 실행

$ mysql -u root -p

비번입력하면

mysql> 창 뜨면서 시작~

 

 

ref: https://cocoze.tistory.com/93

+ Recent posts