This is the 18th day of my participation in the August Genwen Challenge.More challenges in August

An overview of the

In the development process, there will inevitably be a lot of data to store and read. Such as account information, student scores and so on. These data need to use the database, there are many commonly used databases, this paper mainly introduces MySql database, because MySql consideration is relatively small.

The MySql database

Database download

Of course, many people use the command prompt to install the database, but feel that way is a bit troublesome, so directly download the MSI file. Go to the download page of the MySQL official website.MySQL Community Downloads)chooseMySQL Installer for WindowsEnter the Download page

You will see that you have two download options

  • The first one (2.4m in size) is an online installation that will download the installation package online.
  • The second (450.7 MB in size) is an offline installation. Here we choose the second (the one in the red box above, which already contains both 32-bit and 64-bit installation packages) and download it locally for installation. Click “Downloda” to enter the download page.

On the download page, select No thanks, just start my Download.

Database Installation

Here the database installation is directly a fool installation, but there are a few points to note as follows

Select the Installation Type

We don’t need a lot of functionality here, so just select ServerOnly

Password Authentication Method

Mysql is recommended to use the latest database and related clients. MySQL8 has changed its encryption plugin, so if you choose the first method, it is likely that your navicat or other clients will not be able to connect to MySQL8. Can also be their own Baidu how to solve

The second one does not have this problem.

Set the password

Remember your password

Failed to start the service during the last check

In the end, if StartingServer fails to install detection, do not shoot, just follow the following method

The failed picture was cut out, as shown belowThe solution is as follows: Enable the service

Find MYSQL and double click on it

In the pop-up dialog box, there are four options: general, Login, Recovery, and dependency

Select login: there are two options in the following login id, 1 is the local system account, 2 is this account, the default choice should be 2 this account, and password, all you need to do is to select the local system account, click Apply, then start the service, and everything is done.

Verify the installation

Find MySQL Command in the Start menu… Click and a command prompt appearsEnter the database password in the command prompt

If the database version is displayed, the database is successfully installed.

Connect to the database in Unity

*** Editor/Data/Mono/lib/Mono / 2.0 *** Editor/Data/Mono/lib/Mono / 2.0 *** Editor/Data/Mono / 2.0

  1. I18N.CJK.dll
  2. I18N.dll
  3. I18N.West.dll
  4. System.data.dll
  5. System.Drawing.dll

Mysql.data. DLL; Connect to the database, first need to set the database address, database name, database port, user name, password, these are set up before you can set the database connection information

string mySqlString = string.Format("Database=Student; Data Source = 127.0.0.1; User Id=root; Password=root; port=3306; charset=utf8");Copy the code

Charset = UTf8; error may occur if charset=utf8 is not written

The next step is to connect

 private static MySqlConnection mySqlConnection;
 mySqlConnection = new MySqlConnection(mySqlString);
 mySqlConnection.Open();
Copy the code

If there are no errors, congratulations, you have successfully connected to the database.

Write in the last

This article mainly introduces the installation of MySql database, and how to connect to the database in Unity, the next article will introduce the increase, deletion, change, check and other data operations in Unity database.