MySQL | mysql 완전삭제한 과정(MacOS)

2022. 7. 2. 19:15·기타
반응형

mysql 설치후 

mysql.server start

로 서버를 시작후

 

mysql_secure_installation

으로 초기설정을 하다가 

비밀번호 복잡도 설정에 실수로 y를 눌렀다.

Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve securitNy. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:

여기에 y를 누르니까 비밀번호를 입력해도 조건에 안맞는다고 뒤로 안넘어갔다ㅠ

참고로 mysql 비밀번호 조건..

나도 접속을 못할거같아서 삭제하고 다시 깔기로 했다

1차시도

brew uninstall mysql 로 삭제하고 다시 깔고 다시 설정을 했다

brew uninstall mysql
brew install mysql
mysql.server start
mysql_secure_installation

결과:

(base) ~ % brew uninstall mysql
Uninstalling /usr/local/Cellar/mysql/8.0.29... (311 files, 296.2MB)
(base) ~ % brew install mysql
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
podman-compose

You have 1 outdated formula installed.
You can upgrade it with brew upgrade
or list it with brew outdated.

==> Downloading https://ghcr.io/v2/homebrew/core/mysql/manifests/8.0.29
Already downloaded: ///Library/Caches/Homebrew/downloads/7e1024303fbfa1839b3a1eee037d5a086214c4ce033c85a30a26685993dc6c43--mysql-8.0.29.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/blobs/sha256:c5ff449dce2b
Already downloaded: ///Library/Caches/Homebrew/downloads/155d92528055d781bfa0636d4c1fa7952c9957d005f901927416a1bfa91b1124--mysql--8.0.29.catalina.bottle.tar.gz
==> Pouring mysql--8.0.29.catalina.bottle.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To restart mysql after an upgrade:
  brew services restart mysql
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.29: 311 files, 296.2MB
==> Running `brew cleanup mysql`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
(base) ~ % mysql.server start
Starting MySQL
 SUCCESS! 
(base) ~ % 2022-06-27T01:14:22.6NZ mysqld_safe A mysqld process already exists
mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here.

New password:

설정하던게 있다고 바로 또 복잡한 비밀번호 삭제하는 화면으로 넘어갔다...

그래서 일단 복잡한 비밀번호를 설정해서 설정을 끝내고

 

2차시도

다른 삭제 명령을 찾아서 써봤다

brew uninstall --force mysql

결과:

which mysql
/usr/local/bin/mysql
(base) ~ % brew uninstall --force mysql
Uninstalling mysql... (311 files, 296.2MB)
(base) ~ % which mysql
mysql not found

mysql 경로 확인하는 which mysql 명령어로

sql이 없는것까지 확인후 재설치:

(base) ~ % brew install mysql
Running `brew update --auto-update`...
To restore the stashed changes to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core, run:
  cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash pop
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).

You have 1 outdated formula installed.
You can upgrade it with brew upgrade
or list it with brew outdated.

==> Downloading https://ghcr.io/v2/homebrew/core/mysql/manifests/8.0.29
Already downloaded: ///Library/Caches/Homebrew/downloads/7e1024303fbfa1839b3a1eee037d5a086214c4ce033c85a30a26685993dc6c43--mysql-8.0.29.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/blobs/sha256:c5ff449dce2b
Already downloaded: ///Library/Caches/Homebrew/downloads/155d92528055d781bfa0636d4c1fa7952c9957d005f901927416a1bfa91b1124--mysql--8.0.29.catalina.bottle.tar.gz
==> Pouring mysql--8.0.29.catalina.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.29/bin/mysqld --initialize-insecure --user=
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To restart mysql after an upgrade:
  brew services restart mysql
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.29: 311 files, 296.2MB
==> Running `brew cleanup mysql`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
(base) ~ % brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
(base) ~ % mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
(base) ~ % mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)
(base)  ~ % mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)
(base) ~ % mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)
(base) ~ % brew services stop mysql
Stopping `mysql`... (might take a while)
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
(base) ~ %

이때도 초기설정이 삭제가 안됐는지 비밀번호를 입력하라고 나오는데

아까 설정한 비밀번호가 먹지 않았음.

 

3차시도(성공)

그래서 진짜진짜 완전삭제하는 법을 찾아서 따라했다.

brew services stop mysql
which mysql
->/usr/local/bin/mysql 이 위치인거 확인하고 아래 명령어를 한줄씩 입력해서 삭제했다

brew uninstall --force mysql

sudo rm -rf /usr/local/mysql
sudo rm -rf /usr/local/bin/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/Cellar/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /tmp/mysql.sock.lock
sudo rm -rf /tmp/mysqlx.sock.lock
sudo rm -rf /tmp/mysql.sock
sudo rm -rf /tmp/mysqlx.sock
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*

그리고 재부팅해서 다시 설치하고 

brew install mysql	# 설치
mysql.server start	# 시작
mysql_secure_installation	# 기본설정시작

결과:

Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve securitNy. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:

드디어 이 멘트가 나오고 비밀번호 복잡도에 no를 선택하고 간단한 비밀번호로 등록할수 있었다!

 

참고

https://github.com/rangyu/TIL/blob/master/mysql/MySQL-완전-삭제하고-재설치하기-(MacOS).md

반응형
저작자표시 비영리 변경금지 (새창열림)

'기타' 카테고리의 다른 글

가상환경 | 미니콘다 설치(Mac), 기본 명령어  (0) 2022.07.15
장고 익스텐션 | 내가 지정한 url 패턴 확인하기  (0) 2022.07.14
개발환경 | django-extensions, ipython 설치하기  (0) 2022.07.14
터미널에서 code 명령으로 vscode 열기  (0) 2022.07.04
맥 catalina(10.15.7) homebrew 설치 안될때  (0) 2022.06.01
'기타' 카테고리의 다른 글
  • 장고 익스텐션 | 내가 지정한 url 패턴 확인하기
  • 개발환경 | django-extensions, ipython 설치하기
  • 터미널에서 code 명령으로 vscode 열기
  • 맥 catalina(10.15.7) homebrew 설치 안될때
이라후
이라후
  • 이라후
    화이팅
    이라후
  • 전체
    오늘
    어제
    • 분류 전체보기 (133)
      • TIL (23)
      • 기타 (26)
      • Python (14)
      • Django (10)
      • JavaScript (8)
      • git & GitHub (8)
      • Web (10)
      • Go (3)
      • wecode (31)
  • 반응형
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
이라후
MySQL | mysql 완전삭제한 과정(MacOS)
상단으로

티스토리툴바