Page 1 of 1

sha2_password

Posted: Sat Jan 04, 2025 2:28 pm
by serge_girard
How to connect to mySQL- caching_sha2_password ?

Serge

Re: sha2_password

Posted: Sat Jan 04, 2025 6:49 pm
by franco
I am not sure what you are looking for.
I have found when using Microsoft Edge, after going in, in the top right corner is a red and green flag.
If you click it a copilot box will be a bottom of screen.
You can ask in that box any question about anything including programing questions.
Like
How to create a menu in c# language.
How to create a menu in hmg language.
How to connect to mySQL- caching_sha2_password ? in hmg language.
Most answers you get are quite accurate.

Re: sha2_password

Posted: Sun Jan 05, 2025 1:10 pm
by serge_girard
Thanks Franco,

I wil try with CHATgpt

Serge

Re: sha2_password

Posted: Sun Jan 05, 2025 6:09 pm
by franco
You can ask it in language you like.
It will create code for you in any language.
Ask it .... create menu in hmg language or ..... create menu in gui language.
It will create the code for you which you can compile with a build.bat

It will give you an explanation plus the code. You do not need CHATgpt I don`t think.

if you ask it
connect to mySQL- caching_sha2_password ? in hmg language.

CREATE USER 'yourusername'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpassword';
GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost';
FLUSH PRIVILEGES;

Re: sha2_password

Posted: Sun Jan 05, 2025 6:58 pm
by serge_girard
From chatgpt:

Code: Select all

#include "hmg.ch"
REQUEST HB_MYSQL

FUNCTION Main()
    LOCAL oMySql, cHost, cUser, cPassword, cDatabase, nPort

    cHost := "127.0.0.1"  // MySQL server host
    cUser := "your_username"  // MySQL username
    cPassword := "your_password"  // MySQL password
    cDatabase := "your_database"  // MySQL database name
    nPort := 3306  // MySQL server port

    oMySql := hb_MySQLInit()

    IF oMySql == NIL
        MsgInfo("Failed to initialize MySQL client")
        RETURN NIL
    ENDIF

    IF hb_MySQLConnect(oMySql, cHost, cUser, cPassword, cDatabase, nPort)
        MsgInfo("Connection successful!")
        // Perform database operations here
        hb_MySQLClose(oMySql)
    ELSE
        MsgInfo("Failed to connect: " + hb_MySQLError(oMySql))
    ENDIF

    RETURN NIL
Can't find hb_MySQL* function at the moment, tomorrow perhaps...

S