728x90
반응형
apt-get install mysql
apt-get install mariadb
1. 초기 보안설정
sudo mysql_secure_installation
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y ( 루트 패스워드 설정 여부 )
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] Y ( 익명 사용자 삭제 여부 )
... Success!
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? [Y/n] Y ( root 계정의 원격 접속을 막을껀지 )
... skipping.
By default, MariaDB 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? [Y/n] Y ( test 데이터베이스 삭제 여부 )
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
2. DB 생성 + 원격접속 계정생성 + 권한 추가
sudo mysql
# DB 생성
create database mydatabase default character set utf8;
use mysql;
# test 계정을 1234 비밀번호로 생성
create user 'test'@'%' identified by '1234';
grant all privileges on mydatabase.* to test@'%';
flush privileges;
exit
3. Mysql or MariaDB 설정파일에서 외부접속 허용
# mysql은 다른 설정파일임
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
# bind-address를 주석처리
#bind-address = 127.0.0.1
:wq
service mysql restart
4. 외부에서 접속해보기
※ DEFAULT PORT = 3306
※ 방화벽에서 3306 접근 허용시켜야함
728x90
반응형
'DataBase' 카테고리의 다른 글
MongoDB Security셋팅, 유저생성, Nodejs 연동 + PHP 연동 ( With Ubuntu ) (2) | 2021.07.09 |
---|---|
Ubuntu 18.04 MongoDB 설치 (0) | 2020.06.03 |
AMP 컴파일설치(MySQL) (0) | 2019.03.31 |
댓글