반응형
들어가며
나는 그전에
mysqldump 라는
mysql 백업기능
을 이용해서
만든 파일을
우분투 환경에
설치된 mysql에
적용시킬
것이다.
mysql 파일이 필요하다.
집에서 안쓰는 usb에 담아오면 된다.
1. 그랬다면 바탕화면에 풀어라.
2. 터미널을 오픈한다. 다음과 같이 입력을 해주어라
andante@andante-IdeaPad-1-15IJL7:~$ sudo mysql -uroot -p
[sudo] andante 암호:
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.0.41-0ubuntu0.24.04.1 (Ubuntu)
Copyright (c) 2000, 2025, 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>
3. php에서 dbconn.php 파일을 열은다. 여기서 $db가 가리키고 있는 데이터베이스에 풀어야한다.
<?php
$localhost = 'localhost';
$user = 'root';
$password = '1234';
$db = 'board'; // board 테이블이 있는지 조회한다.
// 첫번째
mysql> SHOW DATABASES LIKE 'board';
Empty set (0.00 sec) // board 디비를 찾을 수 있고 .... 시간초도 줄일수 있다.
// 두번째
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.02 sec) // 시간도 오래 걸리고 만약에 100000개 라면
4. 없으니 데이터베이스를 새로 생성해주자
mysql> CREATE DATABASE board;
Query OK, 1 row affected (0.02 sec)
# 그리고 board 데이터베이스를 사용하므로 USE 명령어를 사용해준다.
mysql> USE board;
Database changed
5. 백업 sql 파일을 board 데이터베이스에 풀어줄것이다.
https://blog.naver.com/ojini21c/221193257989
[Ubuntu][MYSQL] MySql Data Export & Import
MySql에 있는 내역을 이관 하거나, Backup을 받기 위해서 Export 할 수 있습니다. 물론, Data가 많지 ...
blog.naver.com
위의 포스팅에서 나온 방법을 사용할 것이다.
1 ) su라는 리눅스 및 유닉스 계열의 최고 권한자로 접근을 한다.
andante@andante-IdeaPad-1-15IJL7:~$ sudo su
root@andante-IdeaPad-1-15IJL7:/home/andante#
2 ) 다음과 같이 입력해주면 된다.
root@andante-IdeaPad-1-15IJL7:/home/andante/바탕화면# mysql -u root -p [import할 db명] < [db파일명].sql
Enter password:
6. 이게 됬다고 해서 방심하면 된다. 한번더 확인해보자.
USE board; # board 데이터베이스를 사용한다.
SHOW TABLES; # 테이블들을 확인해보겠다.
+-----------------+
| Tables_in_board |
+-----------------+
| board |
| register |
+-----------------+
2 rows in set (0.02 sec)
이로써 Ubuntu에
백업과정까지 끝났다.
'개발 > php' 카테고리의 다른 글
[php] 사용자 계정 탈퇴시 관련 내용들이 삭제되지 않는 오류 해결하기 (0) | 2025.03.05 |
---|---|
php를 우분투에 설치하고 나서 실행시 나왔던 오류!!!! (0) | 2025.02.23 |
[ PHP ] php form 입력을 이용한 계산기 만들어보기 (0) | 2025.02.11 |
[windows] PHP 환경 직접 구축해보기 (1) | 2025.02.11 |