通用的mysql dump程序
可以适用任何sql , 自动识别字段名, gzip压缩 , 带输出buffer , 支持分库分表
需要辅助代码和Makefie , 下面是主程序代码,
/**
* mysql数据表dump程序
* @author : cheng limin
* @date : 2010-1-18
*
* 使用样例:
*./dump_mysql -c ../conf/dump.conf
* -t xml
* -s "select * from * where punish_type != 0"
* -f ctu.txt
*/
#include <iostream>
#include <string>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include "mysql.h"
#include "INIParser.h"
#include "tbZip.h"
using namespace __gnu_cxx;
using namespace std;
#define OUT_FORMAT_TXT 0 /* 输出文件格式 行列格式 */
#define OUT_FORMAT_XML 1 /* 输出文件格式 xml格式 */
/* 从命令行获得的参数 */
string g_confFile = ""; /* 配置文件 */
string g_sectionName = ""; /* 配置文件section节名称 */
string g_sql = ""; /* 需要执行的sql */
string g_fileName = ""; /* 输出文件名 */
/* 从配置文件获得的参数 */
string g_fieldSep = ""; /* 字段结束 */
string g_lineSep = ""; /* 行结尾 */
string g_host = ""; /* 主机名 */
int g_port = 3306; /* 端口号 默认3306 */
string g_user = ""; /* 用户名 */
string g_passwd = ""; /* 密码 */
string g_db = ""; /* 库名 */
string g_charset = ""; /* 数据库字符集 */
int g_compType = 0; /* 输出文件压缩方式 默认0 0=不压缩 1=gzip */
int g_outFormat = OUT_FORMAT_TXT; /* 输出文件格式 , 默认为文本*/
FILE *g_fp; /* 输出文件句柄 */
tbZip *g_tz; /* 压缩文件工具类 */
/**
* 使用帮助
*
* @param progName 程序名
*/
void usage(const char *progName)
{
fprintf(stderr, "************************************************* \n");
fprintf(stderr, "Usage: %s \n", progName);
fprintf(stderr, " -c configeFile 程序的配置文件 \n");
fprintf(stderr,
相关文档:
mysql忘记root密码的解决
一. MySQL密码的恢复方法之一
如果忘记了MySQL的root密码,可以用以下方法重新设置:
1. KILL掉系统里的MySQL进程;
killall -TERM mysqld
2. 用以下命令启动MySQL,以不检查权限的方式启动;
safe_mysqld --skip-grant-tables &
3. 然后用空密码方式使用root用户登录 MySQL;
......
1. 数据库的部署
(1)软件的安装
A. MySql——必须安装在C盘下,否则安装mysql-connector-net-6.2.2后无正确配置
B. mysql-connector-net-6.2.2——将MySql.Data.dll放在Bin文件夹下
(2)数据库的导出导入
MySQL-Front的"另存为"功能可以将数据库导出为.sql文件,然后再通过它直接导入.sql文件� ......
1、取字段注释
Select COLUMN_NAME 列名, DATA_TYPE 字段类型, COLUMN_COMMENT 字段注释
from INFORMATION_SCHEMA.COLUMNS
Where table_name = 'companies'##表名
AND table_schema = 'testhuicard'##数据库名
AND column_name LIKE 'c_name'##字段名
2、取得表注释
Select table_name 表名,TABLE_COMMENT 表注释 ......
在看项目的是看到mysql版本的项目,发现执行多条sql语句是都是先分离一条条的数据库再一条条执行,我想应该有办法一条条执行的吧
所以今天特意的查找了一下
在jdbc下说可以设置连接字符串的时候设置一下
设置成如下的 jdbc:mysql://192.168.3.180/sample?user=root&password=&allowMultiQueries=true
就可以执� ......
存储过程是一种存储在数据库中的程序(就像正规语言里的子程序一样),准确的来说,MySQL支持的“routines(例程)”有两种:一是我们说的存储过程, 二是在其他SQL语句中可以返回值的函数(使用起来和Mysql预装载的函数� ......