본문 바로가기
  • 산에사는 꽃사랑......
컴퓨터/Linux System and Server

MYSQLADMIN 사용법 , 백업 및 복구

by 산에사는꽃사랑 2018. 5. 11.

MYSQLADMIN 사용법



mysqladmin 프로그램은 MySQL 데이터베이스의 관리를 해줍니다.

데이터베이스 생성, 삭제, 특정계정에 새로운 패스워드 주기, 상태, 버전 알기 등의 기능을 가지고 있죠.

만약, 도움말을 보고 싶으면 다음과 같이 입력합니다.


C:\APM_Setup\Server\MySQL\bin>mysqladmin --help


그러면, 도움말이 주욱 나올것인데... 넘 많죠?

지금부터 몇가지만 골라서 기능을 알아보도록 하겠습니다.

물론, sql을 편리하게 관리할수 있는 프로그램들이 있긴 하지만, 기본적으로 개념을 알아둔다면 나중에 더욱 편리할 것이니, 한번씩 실습해 보는 것이 좋습니다.



★ password


원래 처음 MySQL을 설치하면, 패스워드가 입력되어 있지 않습니다.

그러나, APM4를 설치메뉴얼대로 하셨다면, 이미 패스를 집어넣으셨을테니, 이 명령어를 처음 실행시킬 필요는 없습니다.

만약, 처음 패스가 없는 상태라면, 다음과 같이 입력합니다.


C:\APM_Setup\Server\MySQL\bin>mysqladmin -uroot -p password 123456


비밀번호를 123456으로 만드는 명령입니다...

불행히... 도스상에서는 이렇게 적으면, 에러가 나네요...ㅜ.ㅜ

APM4에서 root의 비밀번호 변경법은 '유틸리티'의 [APM]에 올려두었으니, 참고하셔서 바꾸시길 바라구요, 위의 구문으로 한다는 것 정도만 참고하시길...



★ version


MySQL 서버의 버전 정보를 보여주는 명령어입니다.

실행예는 다음과 같습니다.


C:\APM_Setup\Server\MySQL\bin>mysqladmin -uroot -p version

Enter password: ****

mysqladmin  Ver 8.37 Distrib 4.0.4-beta, for Win95/Win98 on i32

Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL license


Server version          4.0.4-beta-max-nt

Protocol version        10

Connection              localhost via TCP/IP

TCP port                3306

Uptime:                 1 hour 1 min 31 sec


Threads: 1  Questions: 13  Slow queries: 0  Opens: 6  Flush tables: 1  Open tabl

es: 0  Queries per second avg: 0.004



★ create


새로운 데이터베이스를 만드는 명령어입니다.

만약, 'lupins'와 'design'이라는 2개의 데이터베이스를 만든다면, 다음과 같이 합니다.


C:\APM_Setup\Server\MySQL\bin>mysqladmin -uroot -p create lupins

Enter password: ****


C:\APM_Setup\Server\MySQL\bin>mysqladmin -uroot -p create design

Enter password: ****


C:\APM_Setup\Server\MySQL\bin>mysql -uroot -p

Enter password: ****

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 16 to server version: 4.0.4-beta-max-nt


Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql> show databases;

+----------+

| Database |

+----------+

| design   |

| lupins   |

| mysql    |

+----------+

3 rows in set (0.00 sec)



★ drop


create와 반대되는 개념으로 데이터베이스를 삭제하는 명령어입니다.

그러면, create에서 만든 'lupins'와 'design' 데이터베이스를 삭제해 보도록 하겠습니다.


C:\APM_Setup\Server\MySQL\bin>mysqladmin -uroot -p drop lupins

Enter password: ****

Dropping the database is potentially a very bad thing to do.

Any data stored in the database will be destroyed.


Do you really want to drop the 'lupins' database [y/N] y

Database "lupins" dropped


C:\APM_Setup\Server\MySQL\bin>mysqladmin -uroot -p drop design

Enter password: ****

Dropping the database is potentially a very bad thing to do.

Any data stored in the database will be destroyed.


Do you really want to drop the 'design' database [y/N] y

Database "design" dropped


C:\APM_Setup\Server\MySQL\bin>mysql -uroot -p

Enter password: ****

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 21 to server version: 4.0.4-beta-max-nt


Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql> show databases;

+----------+

| Database |

+----------+

| mysql    |

+----------+

1 row in set (0.00 sec)


-------------------------------------------------------

출처 : 가비아 웹호스팅

sql root password 설정법


mysqladmin -u root -p password '변경할패쓰워드' 엔터키

Enter password:   -> 현재 패쓰워드 입력 엔터키

-------------------------------------------------------


-------------------------------------------------------

mysql root 접속법


mysql -u root -p

페스워드입력

-------------------------------------------------------



MySQL 특정 테이블 스키마 백업


mysqldump -u root -p -d cacti_db poller_output > poller_output_schema.sql


스키마(schema) 복원


mysql -u root -p cacti < poller_output_schema.sql