Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing MySQL database using c# on unity?

Tags:

c#

mysql

unity3d

I have just started using C# and do not know much about it. I am using the 3d game engine called Unity and trying to write a c# script to access the MySQL database that I am running. The MySQL database is on a different computer. My question is how can I access the MySQL database using C#. I know the username, password and database I want to use, but I can not figure out how to access the database.

like image 956
Cody Avatar asked Jun 10 '13 17:06

Cody


People also ask

Can we connect MySQL with C?

MySQL database is available on most important OS platforms. It runs on BSD Unix, Linux, Windows, or Mac OS. To be able to compile C examples, we need to install the MySQL C development libraries. The above line shows how we can do it on Debian based Linux.

Can I connect database with C?

You can then add a new C source file and replace it with this content. Using the ODBC APIs SQLAllocHandle, SQLSetConnectAttr, and SQLDriverConnect, you should be able to initialize and establish a connection to your database.

How do we connect to MySQL database?

To connect to the database server, confirm that the MySQL Database Server is running on your machine, right-click the Databases > MySQL Server node in the Services window and choose Connect. You might be prompted to supply a password to connect to the server.

How do I view a MySQL database?

1. Open the Command Prompt and navigate to the bin folder of your MySQL Server installation directory. Then connect to the server using the mysql -u root -p command. Enter the password and execute the SHOW DATABASES; command we have discussed above.


1 Answers

You will need to get the C# MySQL driver: http://dev.mysql.com/downloads/connector/net/

And then you will need to follow the MySQL manual for setting it up and using it. It's a standard ADO.NET driver, so you should be able to follow most any C# SQL tutorials out there for additional help.

like image 131
Adrian Avatar answered Sep 28 '22 03:09

Adrian