Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by DanielBonfim · May 26, 2015 at 06:13 AM · c#unity 5databaseunity 4.6mysql

Unity5 to connect mySQL data base using C# - I need help

I need to know if is possible consultation in mysql data base using only unity script in C#?

I already did this consultation an turn, using unity4 and SQLServer, i put here script, an IP, an username, an password and data base name, and i not forget to get an dll "system.data" to using how library, and finaly i got this consultation. But now, I try to consultation in another data base, in mySQL, and i not know if is possible, and how i get it ? please help me.

PS1:I dont like the ideia it, for comunication with database Mysql, i need another script in another language of programation for get information in data base. I say this why, i read arround it, for got it, is necessary that an scrit in another language(for example PHP), whose function, is consultation in data base, to communicate to script C# in unity for works.

PS2: i'm brazilian, and my english is not one of the best, please try understand my question. In portuguese brazil it has been very hard to get more information in unity.

I appreciate any help, Thanks

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image spiceboy9994 · May 27, 2015 at 05:40 PM 0
Share

Check this out

http://forum.unity3d.com/threads/unity-with-mysql.63364/

avatar image DanielBonfim · May 27, 2015 at 06:00 PM 0
Share

Yes , I checked , but I'm not sure if it works in unity 5, and case give an error , I believe that would be difficult for me to indentificasse the error in the plugin or in my project . I've researched and managed to catch a $$anonymous$$ySQL dll, $$anonymous$$ySQLData.dll version 2.0 of .NET, and I believe her good work , however my host where the database does not seem to accept remote access, access an online database for the Unity would be remote access ?

avatar image apple92 · May 28, 2015 at 08:52 AM 1
Share

For simple things you could use the WWWForms (See here ) and send & retrieve information from the Database via PHP Scripts.

This works for simple Data, that doesn't need to be secure and so on. There's also dotNet Connector for $$anonymous$$ysql that can do http tunneling. But I think using WWWForms is easier for simple communication with the server.

You'll probably need to read yourself into the topic "php & mysql", as you need to catch the data from the WWWForm, then validate it and send it to the Database. Sound's easy, but can be quite insecure if implemented wrong.

avatar image DanielBonfim · May 28, 2015 at 10:50 PM 0
Share

Yes , I managed to make the communication by PHP script work, the data I need are simple, but still have the issue of security , the WWW what alternatives I have about it? but in any case , thank you.

avatar image apple92 · May 29, 2015 at 08:08 PM 0
Share

If you need help again let me know.

It seems you are quite new to Unity Answers. So just in case you didn't know:

If you find a Answer helpful, it would be very kind of you if you could accept it as an Answer.

If you Accept it, your Question gets marked Green, indicating that it was answered, so other peoples don't have to look through thousand of "unanswered" Questions, that are actually already answered.

If you don't know how to accept an answer, then you can look that up here. It's the check mark icon beside the Answer.

Regards $$anonymous$$ichael

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by apple92 · May 29, 2015 at 08:24 AM

(I think I did write it a bit unclear in the comment, so here's a full explanation)

WWWForms with a PHP Script Validating the Data is already the most secure way without a dedicated Server. You only need to run a few checks before your PHP Script writes into the Database.

Including a MYSQL Connector (like rlharper suggested) is over the top and even worse Security wise, because you should never ever let a Client directly talk to the Database. You'd need to do the Validation inside your Game and even leave the password to the database there. Believe me it's pretty easy to decompile any .Net Application. So basicly you would give your Database Password to anyone out there in the World.

Of Course that changes when using a Dedicated Server, that first Validates all inputs and then speaks to the Database, but again, that's a bit over the Top.

The only Problem with WWWForms is (and that's the same for all communication between Client and Server/Database):

You can't trust the Data that is sent by the User. They could simply intercept any Packages sent, modify it and send something completely different to your Database.

So what you would need to check in your PHP Scripts are at least the following things:

  1. Use prepared Statements (MySqli)

  2. Check the incoming Data for Characters that shouldn't be there, like ,.?!()^ and so on.

  3. If you want to make it a bit harder for cheaters (for example if you are doing a Highscore List) then encrypt your data. Though if decompiled, one would still be able to change the Values sent.

(1) Prepared Statements are already a very good way to disallow injection of sql code. (See here)

(2) By striping dangerous Chars like the Question Mark (?) and so on, you minimize the danger of php injection. (See here). If the data doesn't need to be case sensitive, you could also cast all input to lowercase after removing the special chars (Just an easy additional Layer).

You might want to read yourself even more into PHP Security. But I think thats a good start.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by rlharper · May 29, 2015 at 05:41 AM

You could try my approach, here at http://islesofdulst.com/iod/c-odbc/.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DanielBonfim · May 29, 2015 at 04:57 PM 0
Share

yes, it's something, I could access the database from C # direct Unity , however, I use an online hosting , and it seems that she does not accept remote access for security reasons , I still do not know for sure whether access the database by unity through C # would be remote access, but thank you , in a sense his approach gave me some sense beyond which I had done.

avatar image Jeshira · Dec 31, 2017 at 02:14 PM 1
Share

Broken link.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SocketException: No connection could be made because the target machine actively refused it. 0 Answers

animation play on click 1 Answer

Multiple Cars not working 1 Answer

Access a MySQL database via C# ? 2 Answers

MySql Online Character About 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges