我知道这很简单,但我搞不懂。
我在使用。下面的代码是用mysql源代码编写的(在sql_parse.cc文件中)。我需要检查一下错误信息。我怎么才能收到这些信息?我认为这个错误消息不会显示在我运行mysql客户机/服务器的控制台中吗?
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
{
string hashed;
int sockfd, n;
char buf[MAXDATASIZE], url[MAXDATASIZE], ack[6];
struct hostent *he;
struct sockaddr_in remote_addr;
if ((he=gethostbyname("localhost")) == NULL) { // get the host info
perror("gethostbyname");
exit(1);
}
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
exit(1);
}
remote_addr.sin_family = AF_INET; // host byte order
remote_addr.sin_port = htons(PORT); // short, network byte order
remote_addr.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(remote_addr.sin_zero), '\0', 8); // zero the rest of the struct
if (connect(sockfd, (struct sockaddr *)&remote_addr, sizeof(struct sockaddr)) == -1) {
perror("connect");
exit(1);
}请帮帮我..。
发布于 2012-02-07 08:11:54
streams.
中的自定义place (如文件或stdout-)。
例如,在编译代码之后,让我们假设一个创建为"myprogram“的程序文件
如果您以这种方式运行此文件:
./myprogram 2>&1您可以在控制台中看到恐怖错误。
对于您的特殊情况,需要阅读Mysql错误日志。在Debian中,Mysql文件表示:
错误日志由于/etc/mysql/conf.d/mysqld_safe_syzab.cnf而转到syslog。
因此,您可以通过读取syslog文件来读取这些错误。您可以通过文本编辑器读取syslog,也可以读到较少的尾,等等:
sudo gedit /var/log/sysloghttps://stackoverflow.com/questions/9172782
复制相似问题