설치
다음 링크에서 Ubuntu 버전 및 MariaDB 버전을 선택하면 설치 방법을 알려 줍니다.
Ubuntu 12.04, MariaDB 10.0을 선택한 경우 설치 과정은 다음과 같습니다.
sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.kaist.ac.kr/mariadb/repo/10.0/ubuntu precise main'
sudo apt-get update
sudo apt-get install mariadb-server
설치 과정에서 root 비밀번호를 설정합니다.
테스트
$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.0.7-MariaDB-1~precise-log mariadb.org binary distribution
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
Node.js Binding
var inspect = require('util').inspect;
var Client = require('mariasql');
var c = new Client();
c.connect({
host: '127.0.0.1',
user: 'foo',
password: 'bar',
db: 'mydb'
});
c.on('connect', function() {
console.log('Client connected');
})
.on('error', function(err) {
console.log('Client error: ' + err);
})
.on('close', function(hadError) {
console.log('Client closed');
});
c.query('SELECT * FROM users WHERE id = :id AND name = :name',
{ id: 1337, name: 'Frylock' })
.on('result', function(res) {
res.on('row', function(row) {
console.log('Result row: ' + inspect(row));
})
.on('error', function(err) {
console.log('Result error: ' + inspect(err));
})
.on('end', function(info) {
console.log('Result finished successfully');
});
})
.on('end', function() {
console.log('Done with all results');
});
c.query('SELECT * FROM users WHERE id = ? AND name = ?',
[ 1337, 'Frylock' ])
.on('result', function(res) {
res.on('row', function(row) {
console.log('Result row: ' + inspect(row));
})
.on('error', function(err) {
console.log('Result error: ' + inspect(err));
})
.on('end', function(info) {
console.log('Result finished successfully');
});
})
.on('end', function() {
console.log('Done with all results');
});
c.end();