[MacOS] Mysql μ€μΉ λ°©λ²
homebrewλ‘ MySQL ν¨ν€μ§ μ€μΉ λ°©λ²
MySQL ν¨ν€μ§ κ²μ
> brew search mysql
==> Formulae
automysqlbackup mysql-client mysql-sandbox mysql@5.7
mysql mysql-client@5.7 mysql-search-replace mysqltuner
mysql++ mysql-connector-c++ mysql@5.6 qt-mysql
==> Casks
mysql-connector-python mysql-utilities navicat-for-mysql
mysql-shell mysqlworkbench β sqlpro-for-mysql
MySQL μ€μΉ λ°©λ²
brew install mysql
: μ΅μ mysql ν¨ν€μ§λ₯Ό λ€μ΄λ°μ μ μμ΅λλ€.brew install mysql@5.7
: mysql 5.7λ²μ ν¨ν€μ§λ₯Ό λ€μ΄λ°μ μ μμ΅λλ€.
mysql@λ²μ : μνλ λ²μ μ μ ννμ¬ λ€μ΄λ°μ μ μμ΅λλ€.
mysql@5.7μ μ€μΉνμμ΅λλ€.
MySQL μ€μΉ νμΈ λ°©λ²
brew list
λ₯Ό ν΅ν΄ μ€μΉλ νλͺ©μ μ‘°νν μ μμ΅λλ€.
> brew list
mysql@5.7
MySQL μμ λ°©λ²
brew remove mysql@5.7
brew list
λ₯Ό ν΅ν΄ μμ λμλμ§ νμΈμ΄ κ°λ₯ν©λλ€.
MySQL μ€μ λ°©λ²
νκ²½ λ³μ μΆκ°
- bash shellμ΄ μλ zsh shellμ κΈ°μ€μΌλ‘ μμ±νμμ΅λλ€
> echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
νκ²½ λ³μ μ μ©
> source ~/.zshrc
MySQL μλ² μ€ν/μ€μ§
mysql.server start
λͺ
λ Ήμ΄λ‘ MySQL μλ²λ₯Ό μ€νμν΅λλ€.
> mysql.server start
Starting MySQL
SUCCESS!
mysql.server stop
λͺ
λ Ήμ΄λ‘ MySQL μλ²λ₯Ό μ€μ§μν¬ μ μμ΅λλ€.
MySQL μ€μ
MySQL μ€μ μ νκΈ° μν΄μλ mysql_secure_installation
λͺ
λ Ήμ΄λ₯Ό μ
λ ₯ν©λλ€.
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 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:
λΉλ°λ²νΈ μ ν μ ν
λΉλ°λ²νΈ κ°μ΄λ μ€μ μ λν μ§λ¬Έμ λλ€.
Yes
: 볡μ‘ν λΉλ°λ²νΈ μ€μ No
: μ¬μ΄ λΉλ°λ²νΈ μ€μ
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: No
No
λ₯Ό μ ννμ΅λλ€.
λΉλ°λ²νΈ μ€μ
μ¬μ©ν μλ‘μ΄ λΉλ°λ²νΈλ₯Ό μ λ ₯ν©λλ€.
Please set the password for root here.
New password:
Re-enter new password:
λΉλ°λ²νΈλ κ°λ¨νκ² mysql
λ‘ νμ΅λλ€.
μ¬μ©μ μ€μ
Remove anonymous users? (Press y|Y for Yes. any other key for No)
μ¬μ©μ μ€μ μ νλ λΆλΆμ
λλ€.
Yes
: μ μνλ κ²½μ°mysql -u root
μ²λΌ -u μ΅μ νμNo
: μ μνλ κ²½μ°mysql
μ²λΌ -u μ΅μ λΆνμ
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) : Yes
Yes
λ₯Ό μ ννμ΅λλ€.
μ격 μ μ μ€μ
Disallow root login remotely? (Press y|Y for Yes, any other key for No)
λ€λ₯Έ IPμμ root μμ΄λλ‘ μ격μ μμ νμ©νλμ§μ λν μ€μ μ
λλ€.
Yes
: μ격μ μ λΆκ°λ₯No
: μ격μ μ κ°λ₯
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) : No
Yes
λ₯Ό μ ννμ΅λλ€.
TEST λ°μ΄ν°λ² μ΄μ€ μ€μ
Remove test database and access to it? (Press y|Y for Yes, any other key for No)
Test λ°μ΄ν°λ² μ΄μ€λ₯Ό μ€μ νλ μ§λ¬Έμ
λλ€
Yes
: Test λ°μ΄ν°λ² μ΄μ€ μ κ±°No
: Test λ°μ΄ν°λ² μ΄μ€ μ μ§
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) : Yes
Yes
λ₯Ό μ ννμ΅λλ€.
λ³κ²½λ κΆνμ ν μ΄λΈμ μ μ©νλ μ€μ
Reload privilege tables now? (Press y|Y for Yes, any other key for No)
λ³κ²½λ κΆνμ ν
μ΄λΈμ μ μ©νλ μ€μ μ λν μ§λ¬Έμ
λλ€.
Yes
: μ μ© μν¨λ€No
: μ μ©μν€μ§ μλλ€
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) : Yes
Yes
λ₯Ό μ ννμ΅λλ€.
μ€μ μλ£
- All done!μ΄ λ¨λ©΄ λͺ¨λ μ€μ μ΄ λμ λλ€.
MySQL DB λ‘κ·ΈμΈ/λ‘κ·Έμμ
mysql -uroot -p
λͺ
λ Ήμ΄λ₯Ό μ
λ ₯ν μμμ μ€μ ν λΉλ°λ²νΈλ₯Ό μ
λ ₯ν λ‘κ·ΈμΈν©λλ€.
> mysql -uroot -p
Enter password:
- μ μμ μΌλ‘ λ‘κ·ΈμΈμ΄ λλ©΄ mysql> λμ΅λλ€.
> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.35 Homebrew
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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>
mysql> μμμ exit
or quit
λͺ
λ Ήμ΄λ‘ λ‘κ·Έμμν μ μμ΅λλ€.
mysql> exit or quit
Bye
MySQL μ€ν μ μ°¨
- MySQL μλ² μμ :
mysql.server start
- MySQL DB λ‘κ·ΈμΈ :
mysql -uroot -p
- MySQL DB λ‘κ·Έμμ :
exit λλ quit
- MySQL μλ² μ’
λ£ :
mysql.server stop
reference
macOS MySQL μ€μΉ λ° μ€μ μ¬μ©λ²
MySQL μ€μΉμ μ΄κΈ° μ€μ for macOS
MacOS brewλ‘ mysql5.7 μ€μΉ
mysql5.7 λ²μ homebrew λ‘ μ€μΉ