본문 바로가기
IT

MariaDB 디렉토리 이동 완료

by Oh.mogilalia 2021. 8. 4.

mogibu@mogibu:~/apm/www$ sudo mkdir mysql

mogibu@mogibu:~/apm/www$ ls

htaccess mysql nextcloud server.csr server.key.orig info.php nc-data server.crt server.key wordpress

mogibu@mogibu:~/apm/www$ sudo systemctl stop mariadb

mogibu@mogibu:~/apm/www$ sudo cp -R -p /var/lib/mysql/* /home/mogibu/apm/www/mysql

mogibu@mogibu:~/apm/www$ sudo chown mysql:mysql mysql

mogibu@mogibu:~/apm/www/mysql$ ls -al
total 176228
drwxrwxr-x+ 7 mysql mysql 4096 Aug 4 10:04 .
drwxr-xr-x+ 75 mogibu mogibu 4096 Jul 27 11:55 ..
-rw-rw—-+ 1 mysql mysql 16384 Aug 4 10:04 aria_log.00000001
-rw-rw—-+ 1 mysql mysql 52 Aug 4 10:04 aria_log_control
-rw-rw-r–+ 1 root root 0 Aug 1 12:19 debian-10.3.flag
-rw-rw-r–+ 1 mysql mysql 13140 Aug 4 10:04 ib_buffer_pool
-rw-rw—-+ 1 mysql mysql 79691776 Aug 4 10:04 ibdata1
-rw-rw—-+ 1 mysql mysql 50331648 Aug 4 10:04 ib_logfile0
-rw-rw—-+ 1 mysql mysql 50331648 Aug 3 14:46 ib_logfile1
-rw-rw—-+ 1 mysql mysql 0 Jul 25 15:02 multi-master.info
drwx——+ 2 mysql mysql 4096 Aug 1 12:19 mysql
-rw-rw-r–+ 1 mysql mysql 16 Aug 1 12:19 mysql_upgrade_info
drwx——+ 2 mysql mysql 12288 Jul 25 19:11 nextcloud
drwx——+ 2 mysql mysql 4096 Aug 1 12:19 performance_schema
drwx——+ 2 mysql mysql 4096 Jul 26 08:30 phpmyadmin
drwx——+ 2 mysql mysql 4096 Aug 2 08:46 wordpress

mogibu@mogibu:~/apm/www/mysql$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
datadir = /home/mogibu/apm/www/mysql

mogibu@mogibu:~/apm/www/mysql$ sudo nano /etc/apparmor.d/tunables/alias

alias  /var/lib/mysql -> /home/mogibu/apm/www/mysql,

mogibu@mogibu:~/apm/www/mysql$ sudo systemctl restart apparmor

mogibu@mogibu:~/apm/www/mysql$ systemctl daemon-reload
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: ,,, (mogibu)
Password:
==== AUTHENTICATION COMPLETE ===

mogibu@mogibu:~/apm/www/mysql$ systemctl start mysql
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start ‘mariadb.service’.
Authenticating as: ,,, (mogibu)
Password:
==== AUTHENTICATION COMPLETE ===

mogibu@mogibu:~/apm/www/mysql$ sudo mysql -u mogibu -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.30-MariaDB-0ubuntu0.20.04.1-log Ubuntu 20.04

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)]> select @@datadir;
+—————————–+
| @@datadir |
+—————————–+
| /home/mogibu/apm/www/mysql/ |
+—————————–+
1 row in set (0.000 sec)
mogibu@mogibu:~/apm/www/mysql$ sudo rm -R /var/lib/mysql
mogibu@mogibu:~/apm/www/mysql$ ls -al /var/lib/mysql
ls: cannot access '/var/lib/mysql': No such file or directory

'IT' 카테고리의 다른 글

FTP Root 접속 가능하도록 설정  (0) 2021.08.05
wordpress 테마 관련 wp-config.php 편집  (0) 2021.08.05
How to Change MySQL/MariaDB Data Directory on Ubuntu  (0) 2021.08.04
DB 백업 스크립트  (0) 2021.08.02
RSS 생성  (0) 2021.07.31