DB/MariaDB

Raspberry pi MariaDB install

강서버 2023. 6. 12. 20:20
728x90
반응형

1. Install MariaDB server

$ sudo apt install mariadb-server

 

user@raspberrypi:~ $ sudo apt install mariadb-server
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
다음 새 패키지를 설치할 것입니다:
  mariadb-server
0개 업그레이드, 1개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
35.5 k바이트 아카이브를 받아야 합니다.
이 작업 후 73.7 k바이트의 디스크 공간을 더 사용하게 됩니다.
받기:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf mariadb-server all 1:10.5.19-0+deb11u2 [35.5 kB]
내려받기 35.5 k바이트, 소요시간 2초 (21.7 k바이트/초)
Selecting previously unselected package mariadb-server.
(데이터베이스 읽는중 ...현재 195316개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../mariadb-server_1%3a10.5.19-0+deb11u2_all.deb ...
Unpacking mariadb-server (1:10.5.19-0+deb11u2) ...
mariadb-server (1:10.5.19-0+deb11u2) 설정하는 중입니다 ...

 

 

2. Set MariaDB root password

$ sudo mysql_secure_installation

 

user@raspberrypi:~ $ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the 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] n
 ... 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
 - 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!

3. MariaDB status check

$ sudo systemctl status mariadb

 

user@raspberrypi:~ $ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.5.19 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-06-12 20:06:08 KST; 5min ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 671 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status>
    Process: 677 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, statu>
    Process: 683 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; />
    Process: 857 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, stat>
    Process: 859 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 761 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 1595)
        CPU: 2.125s
     CGroup: /system.slice/mariadb.service
             └─761 /usr/sbin/mariadbd

 6월 12 20:06:07 raspberrypi mariadbd[761]: 2023-06-12 20:06:07 0 [Note] Plugin 'FEEDBACK' is disabled.
 6월 12 20:06:07 raspberrypi mariadbd[761]: 2023-06-12 20:06:07 0 [Note] InnoDB: Buffer pool(s) load completed>
 6월 12 20:06:07 raspberrypi mariadbd[761]: 2023-06-12 20:06:07 0 [Note] Server socket created on IP: '::'.
 6월 12 20:06:08 raspberrypi mariadbd[761]: 2023-06-12 20:06:08 0 [Note] Reading of all Master_info entries su>
 6월 12 20:06:08 raspberrypi mariadbd[761]: 2023-06-12 20:06:08 0 [Note] Added new Master_info '' to hash table
 6월 12 20:06:08 raspberrypi mariadbd[761]: 2023-06-12 20:06:08 0 [Note] /usr/sbin/mariadbd: ready for connect>
 6월 12 20:06:08 raspberrypi mariadbd[761]: Version: '10.5.19-MariaDB-0+deb11u2'  socket: '/run/mysqld/mysqld.>
 6월 12 20:06:08 raspberrypi systemd[1]: Started MariaDB 10.5.19 database server.
 6월 12 20:06:08 raspberrypi /etc/mysql/debian-start[861]: Upgrading MySQL tables if necessary.
 6월 12 20:06:09 raspberrypi /etc/mysql/debian-start[893]: Checking for insecure root accounts.
lines 1-27/27 (END)

4. MariaDB login

$ mariadb -uroot -p

 

user@raspberrypi:~ $ mariadb -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.5.19-MariaDB-0+deb11u2 Raspbian 11

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

 

 

 

* Uninstall MariaDB server

$ sudo apt remove mariadb-server

 

user@raspberrypi:~ $ sudo apt remove mariadb-server
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
다음 패키지를 지울 것입니다:
  mariadb-server
0개 업그레이드, 0개 새로 설치, 1개 제거 및 0개 업그레이드 안 함.
이 작업 후 73.7 k바이트의 디스크 공간이 비워집니다.
계속 하시겠습니까? [Y/n] y
(데이터베이스 읽는중 ...현재 195319개의 파일과 디렉터리가 설치되어 있습니다.)
Removing mariadb-server (1:10.5.19-0+deb11u2) ...

 

 

* Install MariaDB client

$ sudo apt install mariadb-client

 

user@raspberrypi:~ $ sudo apt install mariadb-client
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
다음 새 패키지를 설치할 것입니다:
  mariadb-client
0개 업그레이드, 1개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
35.4 k바이트 아카이브를 받아야 합니다.
이 작업 후 73.7 k바이트의 디스크 공간을 더 사용하게 됩니다.
받기:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf mariadb-client all 1:10.5.19-0+deb11u2 [35.4 kB]
내려받기 35.4 k바이트, 소요시간 2초 (22.4 k바이트/초)
Selecting previously unselected package mariadb-client.
(데이터베이스 읽는중 ...현재 195319개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../mariadb-client_1%3a10.5.19-0+deb11u2_all.deb ...
Unpacking mariadb-client (1:10.5.19-0+deb11u2) ...
mariadb-client (1:10.5.19-0+deb11u2) 설정하는 중입니다 ...

* Uninstall MariaDB client

$ sudo apt remove mariadb-client

 

user@raspberrypi:~ $ sudo apt remove mariadb-client
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
다음 패키지를 지울 것입니다:
  mariadb-client
0개 업그레이드, 0개 새로 설치, 1개 제거 및 0개 업그레이드 안 함.
이 작업 후 73.7 k바이트의 디스크 공간이 비워집니다.
계속 하시겠습니까? [Y/n] y
(데이터베이스 읽는중 ...현재 195322개의 파일과 디렉터리가 설치되어 있습니다.)
Removing mariadb-client (1:10.5.19-0+deb11u2) ...

728x90
반응형