일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- AVR
- sha1
- assembly
- Pigpen Cipher
- Web Hacking
- Linux
- Masonic Cipher
- Javscript
- JavaScript
- burpsuit
- reversing
- aslr
- Fortran 90
- vigenere cipher
- cookie
- Python
- 비즈네르 암호
- BASE64
- webhacking
- Mail Header injection
- base16
- 카이사르 암호
- 시저 암호
- base32
- Caesar Cipher
- Qrcode
- sql injection
- php_extract
- overthewire
- Navajo alphabet
- Today
- Total
My Drive
[CentOS] CentOS7 MariaDB 5.5 설치 본문
MariaDB 5.5 설치
>> yum -y install mariadb-server mariadb
>> systemctl start mariadb
>> systemctl enable mariadb
* mysql –u root –p 로 접속 안될시
- mysql –u root로 접속 후, use mysql;
- update user set password=password('**********') where user='root';
- flush privileges;
python connector 설치
>> yum install mysql-connector-python
---------------------------------------------------------------------------------------------------------------------------------
# import
import mysql.connector as mariadb
# 계정 연결 및 DB, TABLE 생성
con = mariadb.connect(user='root', password='*****')
cur = con.cursor()
cur.execute('CREATE DATABASE IF NOT EXISTS [DBNAME]')
cur.execute('use [DBNAME]')
cur.execute('CREATE TABLE IF NOT EXISTS [TABLENAME] (IP_ADDR varchar(20) NOT NULL PRIMARY KEY, MAC_ADDR varchar(20) NOT NULL, DATE datetime NOT NULL)')
# select문 예시
query = "SELECT IP_ADDR from [TABLENAME] where MAC_ADDR=\"[MAC]\""
cur.execute(query)
if cur.fetchone() != None :
ip = cur.fetchone()[0]
# insert문 예시
query = "INSERT INTO [TABLENAME] VALUES (\"" + [IP] + "\", \"" + [MAC] + "\", \"" + [TIME] + "\")"
cur.execute(query)
# 종료
con.commit()
con.close()
---------------------------------------------------------------------------------------------------------------------------------
C connector 설치
>> http://dev.mysql.com/downloads/connector/c/ 에서 development libraries rpm 다운 (mysql-connector-c-devel-6.1.6-1.el7.x86_64.rpm)
>> rpm –i PACKAGE.rpm
>> yum install mysql-devel
* conflict 발생하면
- rpm -ev mysql-connector-c-devel
* 컴파일 옵션
- gcc -o [OUTPUT] [SOURCE] -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient
---------------------------------------------------------------------------------------------------------------------------------
// include
# include <mysql.h>
// 계정 연결
con = mysql_init(NULL);
if (mysql_real_connect(con, HOSTNAME, USERNAME, PASSWORD, DBNAME, PORTNUM, SOCKNAME, 0) == NULL)
printf("[Err] connect to database : %s\n", mysql_error(con));
# select문 예시
int i, cnt;
char *query = "select IP_ADDR from [TABLENAME] where MAC_ADDR=\"[MAC]\""
if(mysql_query(con, query))
printf("[error]check ip %s\n", mysql_error(con));
result = mysql_store_result(con);
cnt = mysql_num_fields(result);
for(i=0; i<cnt; i++)
printf("%s ", row[i]);
---------------------------------------------------------------------------------------------------------------------------------
'linux' 카테고리의 다른 글
[CentOS] NFQUEUE 설치 및 설정 (0) | 2016.02.18 |
---|---|
[CentOS] CentOS7 웹서버 (http, https) (0) | 2016.02.18 |
[CentOS] CentOS7 Minimal 기본 설정 (0) | 2016.02.18 |
시스템 문제 만들때 (0) | 2014.09.29 |
[Ubuntu] 리눅스 설치 후 (0) | 2014.09.29 |