-
Notifications
You must be signed in to change notification settings - Fork 345
Tips: Using MySqlConnector + MySqlBackup.NET in CentOS (Linux) #1123
-
I'm one of the main contributor for MySqlBackup.NET project, that works on top of MySqlConnector to perform backup & restore of MySQL databases.
The following explained the idea of using MySqlConnector +MySqlBackup.NET in CentOS (Linux).
The idea is to build the project in .NET Core.
We can test this out with a simple Console App.
Starting by creating a .net core linux project:
Check the project properties, ensure the project is built with .NET Core framework:
Install Nuget Package of MySqlBackup.NET (with MySqlConnector):
Next, is to publish the project for .NET Core (Linux):
In above example, the Linux compiled binaries are located at:
\bin\Release\netcoreapp3.1\publish\linux-x64
Copy the DLL in above folder and paste it to your CentOS
At the CentOS, make sure that you have installed Dotnet runtime by following command:
sudo dnf install dotnet-sdk-<version>
For example:
sudo dnf install dotnet-sdk-3.1
sudo dnf install dotnet-sdk-5.0
Assume that you have copied your .NET Core DLL files at the following folder:
/home/<username>/testapp
Then you can test out your app with following command:
cd /home/admin/testapp
dotnet ConsoleApp.dll
Here is the sample source code for your referrence:
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Replies: 2 comments
-
I may have the exact command-line slightly wrong, but you should be able to run something like dotnet publish -p:PublishSingleFile=true -c Release --self-contained --arch x64 --os linux
to produce a binary that can run without needing to install the .NET runtime on the target system.
See https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file for more info.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Publishing self-contained binary can also be done at Visual Studio GUI
Here is the example of how it looks like, there is only 1 single file:
Copy the compiled binary to CentOS
At the terminal, browse to the folder that contains the self-contained binary, for example:
cd /home/admin/testapp
Next, is to allow execution permission to the file:
sudo chmod 777 ConsoleApp2
Execute the app:
./ConsoleApp2
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1