0
XAMPP으로 MySQL 데이터베이스 설정에 연결하려고합니다. OSX에서 MySQL Connector C API을 사용하고 있습니다. 나는 다음과 같은 결과를 얻을MySQL 커넥터 C API MySQL 서버에 연결할 수 없습니다.
MYSQL mysql;
mysql_init(&mysql);
if(!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0))
{
printf("Failed to connect to database: Error (%d): %s",mysql_errno(&mysql),mysql_error(&mysql));
}
else printf("Connection success!");
:이 코드를 사용하여 phpMyAdmin을 여기에, 잘 그것을 연결하기 때문에 데이터베이스를 확인할 수 있습니다
Failed to connect to database: Error (2002): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
가 작동하면 config.inc.php를 파일입니다
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
누구나 phpMyAdmin을 연결할 수 있지만 C 프로그램으로 연결할 수없는 이유를 알고 있습니까? TCP/IP 연결을 사용하지 않으려 고 시도했습니다.
고맙습니다. mySQL가 소켓을 찾는 경로를 찾은 후 MySQL이 청취하는 소켓을 XAMPP 변경합니다. – user293895
제안한대로 포트 3306을 사용해 보았습니다. 작동하지 않았다. – user124384