데이터 베이스 접속시
# mysql --user=root -p
Enter password :
# mysql -u root -p
Enter password :
Enter password :
# mysql -u root -p
Enter password :
MySQL 설치한 직후 root 계정에 password 변경
# mysqladmin -u root password 새비밀번호
# mysql -u root mysql
mysql> update user set password=password('새비밀번호') where user='root';
mysql> flush privileges;
# mysql -u root mysql
mysql> update user set password=password('새비밀번호') where user='root';
mysql> flush privileges;
사용자 추가
mysql> grant all privileges on dbname.* to 'username'@'localhost' identified by 'password';
mysql> flush privileges;
mysql> flush privileges;
사용자 삭제
mysql> delete from user where user='username';
mysql> flush privileges;
mysql> flush privileges;
데이터베이스 생성
mysql> create database dbname;
존재하는 데이터베이스 목록 보기
mysql> show databases;
특정 데이터베이스 사용하기
mysql> user dbname;
데이터베이스 삭제
mysql> drop database dbname;
테이블 생성 예제
mysql> create table tablename ( column_name1 int, column_name2 varchar(20) );
현재 데이터베이스에서 존재하는 테이블 목록 보기
mysql> show tables;
테이블 구조 보기
mysql> explain tablesname;
mysql> describe tablename;
mysql> describe tablename;
테이블 삭제
mysql> drop table tablename;
현재상태보기
mysql> status
--------------
mysql Ver 14.14 Distrib 5.5.10, for Win64 (x86)
--------------
mysql Ver 14.14 Distrib 5.5.10, for Win64 (x86)
Connection id: 156
Current database:
Current user: user@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.10 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 2 hours 18 min 59 sec
Current database:
Current user: user@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.10 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 2 hours 18 min 59 sec
Threads: 1 Questions: 23798 Slow queries: 6 Opens: 188 Flush tables: 1 Open tables: 0 Queries per second avg: 2.853
--------------
--------------
사용자 추가
mysql> grant all on *.* to 'username'@'localhost' identified by 'password';
mysql> grant all on dbname.* to 'username'@'localhost' identified by 'password';
mysql> flush privileges;
mysql> grant all on dbname.* to 'username'@'localhost' identified by 'password';
mysql> flush privileges;
mysql 원격접속 설정
mysql> grant all privileges on dbname.* to 'username'@'접속ip' identified by 'password';
mysql> flush privileges;
mysql> flush privileges;
'System > MySQL' 카테고리의 다른 글
mysql에서 tpc-e 테스트 하기 (0) | 2011.05.03 |
---|