Skip to content

Instantly share code, notes, and snippets.

@vvtommy
Created December 2, 2012 08:35
Show Gist options
  • Save vvtommy/4187735 to your computer and use it in GitHub Desktop.
Save vvtommy/4187735 to your computer and use it in GitHub Desktop.
pam_mysql进行OpenVPN认证的表结构
-- 创建数据库
CREATE DATABASE openvpn;
-- 切换数据库
USE openvpn;
-- 创建用户,用户名openvpn,密码openvpn(可自行设定)
GRANT ALL ON openvpn.* TO 'openvpn'@'localhost' IDENTIFIED BY 'openvpn';
-- 创建用户数据表
CREATE TABLE IF NOT EXISTS `user` (
`username` char(32) COLLATE utf8_unicode_ci NOT NULL,
`password` char(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` int(10) NOT NULL DEFAULT '1',
`creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`email` char(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`note` text COLLATE utf8_unicode_ci,
`quota_cycle` int(10) NOT NULL DEFAULT '30',
`quota_bytes` bigint(20) NOT NULL DEFAULT '10737418240',
`enabled` int(10) NOT NULL DEFAULT '1',
PRIMARY KEY (`username`),
KEY `idx_active` (`active`),
KEY `idx_enabled` (`enabled`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- 创建日志数据表
CREATE TABLE IF NOT EXISTS `log` (
`username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`end_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`trusted_ip` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`trusted_port` int(10) DEFAULT NULL,
`protocol` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`remote_ip` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`remote_netmask` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`bytes_received` bigint(20) DEFAULT '0',
`bytes_sent` bigint(20) DEFAULT '0',
`status` int(10) NOT NULL DEFAULT '1',
KEY `idx_username` (`username`),
KEY `idx_start_time` (`start_time`),
KEY `idx_end_time` (`end_time`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment