Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Pls, help with error with Mysql

Discussion in 'Scripting' started by danzokulov, Oct 2, 2023.

  1. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    Please, help me with errors
    [10:09:08] Assembly 'Library/ScriptAssemblies/Assembly-CSharp.dll' will not be loaded due to errors: Reference has errors 'MySql.Data'.
    [10:09:08] Assembly 'Library/ScriptAssemblies/Assembly-CSharp-Editor.dll' will not be loaded due to errors: Reference has errors 'Assembly-CSharp'.
    [10:09:08] Assembly 'Assets/Libraries/MySql.Data. dll' will not be loaded due to errors: Unable to resolve reference 'Google.Protobuf'. Is the assembly missing or incompatible with the current platform?

    i installed Mysql.Data.dll
    thank you in advance
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,251
    How did you 'install' that?
    You need a framework compatible with C#/.NET
     
  3. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    What do you mean?
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,251
    You said you installed mysql.data.dll
    What do you mean with that
     
  5. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    I put it in Libraries folder
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
    Nad_B and DevDunk like this.
  7. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
    It has its own documentation right on the front page.

    What part of the documentation are you having issues with?
     
  9. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    I done all from this site and i have error
    [09:26:51] Unloading broken assembly Assets/Libraries/MySql.Data.dll, this assembly can cause crashes in the runtime
     
  10. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    This is SQLite though.

    But for games, it's the right choice if you absolutely need a database. You should avoid MySQL/SQL Server/Oracle/Postgres/MariaDB which are overkills, since they need a running database server, while SQLite does not need a server at all (it's just a file).

    You won't ask your players to go and install a MySQL server on their machine just to run your game? right?
     
  11. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,647
    You've forgotten to remove the broken dlls from your previous attempt.
     
  12. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
    This sort of comment makes me wonder if you really even need a database. Hardly anybody uses databases in gaming at the client level. Are you sure that you actually need this level of intense complexity???

    ScriptableObjects are usually how data is authored. It is FAR simpler to use right in the editor.
     
  13. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    I already have server, i need mysql for account system
     
  14. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    it is This is a necessary measure
     
  15. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    Do you really need any advanced 3D/2D Graphics in your app? if it's just an admin/tool app, maybe it's just simpler to use plain .NET and one of its UI frameworks (WinForms, WPF, MAUI, UWP, WinUI...) and not fight against Unity which was not meant to be used to access any database servers.
     
  16. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    NO
    It is 3d game and i must do connect to mysql database for account system. I cant without it
     
  17. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,261
    But where do you host your database? You NEVER directly connect to a mysql database over the internet. Depending on the rights the DB user has, a user could completely screw up your database or manipulate whatever he wants or in the mildest case get access to things he shouldn't. That's why interaction with a database from a game is almost always mediated through an API on a server, most commonly a webserver. For example a php script which does do the database interaction and provides concrete methods / end points that your game can use / query.

    You can't really implement any security or measures against manipulation or any other sort of attack when you expose a DB server directly to the internet. They are not designed for that.

    Since you seem to be very inexperienced with databases, just a friendly warning: you get into very dangerous territory. Especially since you said "account management" you may risk other peoples personal data which can get you into real trouble.

    Are you working on your own or do you work for a company? Because such design decisions should be made by more experienced developers.

    Maybe have a look at this gd.se question. The list of reasons why you shouldn't expose or use a mysql server over the internet is endless.
     
    Nad_B and Kurt-Dekker like this.
  18. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    Exactly.

    When you distribute your game (or any app), it's extremely easy for anybody to decompile your code and have access to any connection string/credentials (username, passwords). Heck even without decompiling, anybody could sniff the packets of your network connection to your database and get the credentials.

    TLDR: Create and use an API instead. It's very easy.
     
  19. danzokulov

    danzokulov

    Joined:
    Oct 1, 2022
    Posts:
    22
    I know it, but i want it. When i do it, i will create security, but i want DONE it first, and then i will protect it
     
  20. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    You just cannot protect it. It's impossible.

    Anyway if you insist, this may help you:
    https://github.com/Uncle-Uee/mysql-unity
     
  21. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,261
    Well, we already explained that you shouldn't do it for games, we explained that it can not be made secure, that it is slow and not recommended at all. Though if you want to do it anyways, here's an older question where I even tried it with the latest mysql connector and provided an example which I actually tested successfully.

    Though note that the question over there also did not open the mysql server to the internet and just required his server application to use the local database.
     
    Nad_B likes this.