Mysql
๋ก๊ทธ์ธ ๋ฐฉ์์ ๋ณ๊ฒฝ
์์ฆ mysql์์ ๋ก๊ทธ์ธ๋ฐฉ์์ด ๋ณ๊ฒฝ๋์๋ค๊ณ ํ๋ค.
์ค๋๋ง์ ์ค์นํ๋ค๊ฐ ๋งจ๋ถ์ ๋น ์ง.
์ ๋ฆฌํด๋ณด๋ฉด ๋๊ฐ์ง ๋ฐฉ์์ด ์๋ค.
unix_socket ์ธ์ฆ
mysql_native_password ์ธ์ฆ
unix_socket ์ธ์ฆ
์ ๋์ค ๊ณ์ด ์ด์์ฒด์ ์ ์ฌ์ฉ์ ๊ณ์ ๊ณผ mysql์ ์ฌ์ฉ์ ๊ณ์ ์ ์ผ์น์ํค๋ ์ธ์ฆ ๋ฐฉ์
ubuntu 20.04์์ ์ค์น
sudo apt update -y
sudo apt install mysql-server -y
systemctl status mysql
sudo mysql_secure_installation
> Press y|Y for Yes, any other key for No: n
> password
> Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
> Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
> Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
> Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
์ด์ ์ ์ํด๋ณด์.
sudo mysql
show databases;
๋ก๊ทธ์ธ์ด ๋๋ค.
mysql_secure_installation
์์ ์ค์ ํ ํจ์ค์๋๊ฐ ์๋๋ผ๋ ๋ก๊ทธ์ธ์ด ๋๋ฒ๋ฆฐ๋ค.
์ ๋์ค ๊ณ์ด ์ด์์ฒด์ ์ root ๊ณ์ (๋๋ root ๊ณ์ ์ ๊ถํ์ ๊ฐ์ง ๊ณ์ )์ mysql์ root ๊ณ์ ์ ์์ ํ์ฌ ๊ด๋ฆฌํ ์ ์๋๋ก ํ ๊ฒ
์ด unix_socket ์ธ์ฆ์ ์ฌ์ฉํ๋ฉด ์ ๋์ค ๊ณ์ด ์ด์ ์ฒด์ ์ ๋ฃจํธ ์ฌ์ฉ์๊ฐ ์์ ๋ฐ ์คํํ ํ๋ก์ธ์ค์์ mysql์ ์ฝ์์ ๋ก๊ทธ์ธํ๋ ๊ฒฝ์ฐ ์์ผ ์์คํ ๋ณ์์ ์ ์๋ ๋ก์ปฌ Unix ์์ผ ํ์ผ์ ํตํด ์ํธ ์ ๋ ฅ ์์ด ๋ก๊ทธ์ธ ๊ฐ๋ฅ
mysql_native_password ์ธ์ฆ
mysql_native_password ์ธ์ฆ ๋ฐฉ์์ ์ ํต์ ์ผ๋ก ์ฐ์ด๋ ๋ฐฉ์์ผ๋ก ๋ก๊ทธ์ธ ์ ์๋์ ๊ฐ์ด ๊ณ์ ๋ช ๊ณผ ์ํธ๋ฅผ ์ ๋ ฅํ์ฌ ๋ก๊ทธ์ธํ๋ ๋ฐฉ์์ ๋๋ค.
mysql -u root -p
์ ์ ๋ฅผ ์์ฑํด๋ณด์.
CREATE USER 'yourUserName'@'localhost' IDENTIFIED BY 'YourPass';
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'yourUserName'@'localhost';
flush privileges;
์ ๋ฆฌ
root ๋น๋ฒ์ ๋ฃ์ ํ์๋ ์๋๋ฏ ๋ณด์ด๊ณ ์ถ๊ฐ ์ ์ ๋ฅผ ๋ง๋ค์ด์ mysql_native_password๋ฅผ ์ฌ์ฉํ๋ฉด ๋ ๊ฒ๊ฐ๋ค.
์๋ฒ์ ์ ์๋๋ฉด ์๋ฒ์์๋ sudo mysql
ํ๋ฉด root๋ก ๋ก๊ทธ์ธ์ด ๋๋ค.
๋จ์ ์ผ๋ก๋ ์๋ฒ๊ฐ ๋ค๋ฆฌ๋ฉด ์ ๋ถ ๋ค๋ฆฌ๊ฒ๋๋ฐ?
Last updated
Was this helpful?