To connect to mysql database:
- Make sure your mysql server is not bound to localhost - even local connections are via hostname
- Make sure you can connect to mysql server.. grant at least select privs using "grant select on db.* to 'test'@'hostname' identified by 'test';" NOTE: localhost privs are not enough - connection thru hostname.
- Do "export MYSQL_SERVER=hostname"
- Set/export the following environment variables:
A4GL_SQLUID=test #whatever connection user isAnd now take the simple.4gl program:
A4GL_SQLPWD=test #whatever connection password is
A4GL_LEXDIALECT=INFORMIX
A4GL_LEXTYPE=C
A4GL_SQLTYPE=mysql
database test # of whatever your database name is
main
display "Hello World"
end main
Compile with : aubit 4glpc simple.4gl -o simple.4ae
If it compiles - database connection is ok!
Thanks to Mike's comment below - using .aubit4gl.acl to store database:user:pw DOES work.. just be sure to "unset A4GL_SQLUID" and "unset A4GL_SQLPWD".
Hi there..
ReplyDeleteThe ACL file should work for MYSQL too - but only if SQLUID and SQLPWD are not set in the environment.
If either are set - it thinks you want to override the values in the ACLFILE..
If that still doesn't work - let me know and I'll investigate..
Mike A.
Hi Mike,
ReplyDeleteTried again unsetting those variables and you are correct!! It does work.. will amend post.
Thanks!
-Bob