drogon: Can't connect to database (M1 MacOS)

main.cpp

#include <drogon/drogon.h>

int main()
{
  drogon::app().addListener("127.0.0.1", 8848);
  // Load config file
  // drogon::app().loadConfigFile("../config.json");
  drogon::app().createDbClient("mysql", "127.0.0.1", 3306, "database_test", "root", "******").run();

  return 0;
}

When I start the project, I get an unknown error. image

drogon_ctl -v

A utility for drogon
Version: 1.7.5
Git commit: f017b09947badc2e0516355358c8eb7843b44e19
Compilation: 
  Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  Compiler ID: AppleClang
  Compilation flags: -std=c++17 -I/opt/homebrew/include -I/usr/local/include
Libraries: 
  postgresql: no  (batch mode: no)
  mariadb: yes
  sqlite3: yes
  openssl: no
  brotli: no
  boost: no
  hiredis: yes
  c-ares: no

brew ls

ca-certificates	glew		hiredis		mariadb		msgpack		pcre2		ruby
cmake		glfw		jsoncpp		mecab		openssl@1.1	readline	sqlite
cocoapods	groonga		libyaml		mecab-ipadic	pcre		redis		zstd

I can connect to MariaDB by DBeaver: image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 25 (10 by maintainers)

Most upvoted comments

I tried run on Xcode, still no more output. image

I think here you are running the test configuration not the main one. There must be an option in your IDE to change from FromDrogon_test to FromDrogon cmake configuration.

By the way I hope the password in the image is a test one 😅.