Friday, August 16, 2013

C++, MySQL and "access denied" error on Debian Linux

The error message is:

ERR: SQLException in g.cpp(main) on line XX
ERR: Access denied for user 'XX'@'localhost' (using password: NO/YES) (MySQL error code: 1045, SQLState: 28000 )


My solution is:

$ invoke-rc.d mysql stop
$ mysqld --skip-grant-tables

$ g++ \
-finput-charset=utf-8 \
-fexec-charset=utf-8 \
-fwide-exec-charset=utf-8 \
-lmysqlcppconn \
-L/usr/include/mysql \
-lmysqlclient \
-I/usr/include/mysql \
-g whateverfile.cpp -o whateverfile \
`mysql_config --cflags --libs`

$ ./whateverfile


No comments: