connect to mysql
Posted
#1
(In Topic #1521)
Regular

In Visual Basic, I store my formatting cues for tables in a database so I can open different child forms with different formats.
I created a database using mysql workbench, but am getting an error unknown database. I have already verified mysql server is running, and credentials are correct.
I also tried exchanging gb.db2 and gb.db2.mysql for the deprecated gb.db, but there was no change in the error. Also the database name is showing up on the left hand side along with my .csv files.
Here is my code:
in gambas class
public getdb as new connection
public procedure fordbopen()
getdb.close
getdb.type = "mysql"
getdb.host = "localhost"
getdb.login = "myusername"
getdb.port = "3306"
getdb.name = "displaydb"
getdb.password = "mypasswordfordb"
getdb.open()
Posted
Regular

My first guess is on the
Code (gambas)
- getdb.close
(Standard response: Dont use mysql, its a dog. Use MariaDB instead.)
Posted
Regular

Thankyou for the tip on MariaDB, I will check that out.
I tried taking out the close connection, but still got the same error. It is stopping on the last line - getdb.open()
Also I noticed the following in the console:
mysql_opt_reconnect is deprecated and will be removed in a future version.
Posted
Administrator

Try adding "db.Debug = True" as the first line in your fordbopen().
You should get something like
Code
2025-05-30 08:59:29.431 gb.db.mysql: 0x55b544cfc330: select left(version(),6)
2025-05-30 08:59:29.431 gb.db.mysql: 0x55b544cfc330: set names 'utf8'
2025-05-30 08:59:29.432 gb.db.mysql: 0x55b544cfc330: show variables like 'character_set_client'
Posted
Regular

Also tried changing localhost to numerical address. That also didn't work.
Database opens fine in mysql workbench.
Update - apparently I am trying to use the mysql workbench file, not the actual database. Now I have to figure out how to create the database.
Also found dbeaver, so maybe I will try mariadb through that if I can't turn the script generated by workbench into a database.
Definitely got spoiled with Visual Basic on this one!
Posted
Administrator

You run in in your browser and can create databases, tables and such, manage users.
The other method is using cli to do above. Less user friendly, more direct and without an API.
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Regular

Posted
Guru

google Ai said
To export a MySQL database in MySQL Workbench, navigate to Server > Data Export. Choose the database you want to export, select whether to dump structure and data, and choose a local destination file. Then, start the export.
Here's a more detailed breakdown:
1. Open MySQL Workbench and connect to your server:
Establish a connection to the MySQL server containing the database you want to export.
2. Access Data Export:
Go to the Server menu and select Data Export.
3. Select Database and Objects:
In the Data Export pane, choose the database you want to export and specify whether to export the structure (table definitions) and data (table content).
4. Choose Export Options:
You can choose to export to a single SQL file, a project folder, or multiple files (one per table).
5. Configure Advanced Options:
If needed, refine the export operation by adding table locks, using REPLACE statements instead of INSERT, or quoting identifiers.
6. Start the Export:
Click Start Export to initiate the export process. The progress will be displayed.
7. Locate the Exported File:
The exported SQL file will be saved to the location you specified during the export process.
Then i think you would use the Connection.URL property for the exported file.
Posted
Regular

Database opens fine now.
1 guest and 0 members have just viewed this.

