brew services stop mysql
which mysql
brew uninstall --force mysql
혹은
brew uninstall mysql --ignore-dependencies
brew remove mysql
brew cleanup
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/bin/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*
sudo rm -rf /var/db/receipts/com.mysql. *
brew install mysql
brew services list
# mysql none
brew services start mysql
# ==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
brew services list
# mysql started <user이름> ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# 정상적으로 설치됨
mysql_secure_installation
==> Securing the MySQL server deployment.
VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. 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 component?
Press y|Y for Yes, any other key for No:
복잡한 비밀번호 생성을 원하면 👉 y | Y
단순한 비밀번호도 상관없으면 👉 아무 키
공부 목적이고 아직 중요한 자료가 없기 때문에 나는 No를 선택했다. (필요에 따라 선택하면 된다)
그러면 이제 MySQL이 초기에 생성해준 root 계정에 대한 비밀번호를 생성하는 세션이 나온다.
New password: 🔑
Re-enter new password: 🔑
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
Remove anonymous users?
(Press y|Y for Yes, any other key for No) :
익명의 유저 계정을 지울려면 👉 y | Y
익명의 유저 계정을 남겨두려면 👉 아무 키
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely?
(Press y|Y for Yes, any other key for No) :
원격으로 root 계정의 접속을 허락하지 않으면 👉 y | Y
원격으로도 root 계정의 제어를 원하면 👉 아무 키
By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production
environment.
Remove test database and access to it?
(Press y|Y for Yes, any other key for No) :
이 테스트 DB와 그 접근의 삭제를 원하면 👉 y | Y
테스트 DB를 그냥 두고 싶으면 👉 아무 키
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now?
(Press y|Y for Yes, any other key for No) :
지금 로딩할 거면 👉 y | Y
로딩을 원치 않으면 👉 아무 키
이 과정까지 완료했으면 All done! 이 뜨면서 초기설정이 종료된다.
mysql_secure_installation 초기 설정은 이후에도 얼마든지 할 수 있으니 변경하고 싶을 때 해당 명령어를 입력하고 접속하면 된다.
mysql -u root -p
ID : root
PW : 설정한 비밀번호
MySQL의 user (-u)는 root 이며 password(-p)를 사용해서 접속할거야. 라는 의미이다.
mysql>
위와 같이 뜨면 접속 성공
mysql> exit
mysql> quit
둘다 가능하다.
이 명령어는 로그인한 계정(root)의 접속을 해제하는 것으로, MySQL 서버의 연결을 끊는 것과는 다르다.
mysql.server stop
계정의 접속만 해제해두고 서버 연결을 해제하지 않으면, MySQL Server는 계속 열려있게 된다.
따라서 계정 로그아웃 후에 꼭 서버 연결도 해제해 주어야 한다.