로즈마리

글 작성자: daily_zi




처음에 설치를 잘못했는지, mysql 실행 시 아래의 에러가 나서 계속 끙끙거렸다. ㅠㅠ

구글을 통해 여러가지 시도 끝에 해결!


 

  Access denied for user 'root'@'localhost' (using password: NO)




1. mysql과 관련된 디렉토리 및 파일들을 모두 지우고, Mysql을 재 설치한다. 



 $ sudo rm -rf /usr/local/Cellar/mysql

 $ brew cleanup

 $ sudo rm -rf /usr/local/var/mysql

 $ brew install mysql

 $ sudo chown -R _mysql:mysql /usr/local/var/mysql




 $ brew install mysql

==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.13.mojave.bottle.tar.gz

Already downloaded: /Users/jihyang-eun/Library/Caches/Homebrew/downloads/a2e4b03bc64f1132b8ec5082e9cc466d03dad37ac873b5085c587e2a1d6a6bd1--mysql-8.0.13.mojave.bottle.tar.gz

==> Pouring mysql-8.0.13.mojave.bottle.tar.gz

==> /usr/local/Cellar/mysql/8.0.13/bin/mysqld --initialize-insecure --user=jihyang-eun --basedir=/u

==> 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 have launchd start mysql now and restart at login:

  brew services start mysql

Or, if you don't want/need a background service you can just run:

  mysql.server start

==> Summary

🍺  /usr/local/Cellar/mysql/8.0.13: 267 files, 236.6MB


2. mysql_secre_installation 



 $ mysql_secure_installation


3. 복잡한 비밀번호를 사용하도록 제한해주는 플러그인을 사용하겠습니까? NO



 Securing the MySQL server deployment.


 Connecting to MySQL using a blank password.


 VALIDATE PASSWORD PLUGIN 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 plugin?


 Press y|Y for Yes, any other key for No: n



4. 비밀번호 입력


 Please set the password for root here.


 New password: 


 Re-enter new password:




5. 익명 사용자를 삭제 하시겠습니까? Yes


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

Success.




6. 'localhost' 이외에 다른 서버에서 root 아이디로 원격접속을 허용하지 않겠습니까? Yes 


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) : y

Success.




7.  mysql에 기본으로 생성된 test 데이터베이스를 삭제하시겠습니까? No


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) : n


 ... skipping.




8. 변경된 권한을 테이블에 적용하시겠습니까? Yes

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

Success.


All done! 



해결~~!


※추가로 아래는 my.cnf 위치입니다.


$ vi /usr/local/etc/my.cnf