Why would I choose mysql?Because my server configuration is low and the SqlServer instance in the docker, the running memory of the server should be kept at 2G+, I don't have this condition, it will pop out the error sqlservr: This program requires a machine with at least 2000 megabytes of memory. Listen to my friend that even if your machine is 2G, it will report this error and see a lot of cracks on the Internet.Is not friendly, afraid of more problems, so naturally choose MySql, (SqlServer eat configuration is still very high)....
Of course, we should first install the MySQL container in the docker. We can first query the mirror of keywords through the docker search mysql.NAME: Name of Mirror Warehouse Source, DESCRIPTION: Description of Mirror, OFFICIAL: Official release of docker.. If you want to see the actual version, you can go https://hub.docker.com/ Find it in.
[root@iZenarrdqnvpc4Z ~]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation... 8995 [OK] mariadb MariaDB is a community-developed fork of MyS... 3175 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create... 669 [OK] percona Percona Server is a fork of the MySQL relati... 464 [OK] centos/mysql-57-centos7 MySQL 5.7 SQL database server 66 centurylink/mysql Image containing mysql. Optimized to be link... 61 [OK] mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr... 59 deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r... 41 [OK]
Install the MySQL image directly below, using the command docker pull mysql:latest, install the latest version... Ha Ha Ha Ha Ha Ha Ha Ha Ha Ha Ha Ha New Ha Old... a status is ok...
[root@iZenarrdqnvpc4Z ~]# docker pull mysql:latest latest: Pulling from library/mysql 804555ee0376: Pull complete c53bab458734: Pull complete ca9d72777f90: Pull complete 2d7aad6cb96e: Pull complete ............................... Digest: sha256:e1b0fd480a11e5c37425a2591b6fbd32af886bfc6d6f404bd362be5e50a2e632 Status: Downloaded newer image for mysql:latest docker.io/library/mysql:latest
Mysql hanging directories are then created to hold configuration, data, and log files, then the MySQL container is started and the newly created hanging directory is specified, which are executed separately.
mkdir -p $HOME/mysql/{conf.d,data,logs}
docker run --name mysql -p 3306:3306 -v $HOME/mysql/data:/var/lib/mysql -v $HOME/mysql/conf.d:/etc/mysql/conf.d -v $HOME/mysql/logs:/logs --privileged=true -e MYSQL_ROOT_PASSWORD=123456 -d mysql
Enter the MySQL container.Log in to the MySQL service through the root account, and it lets you enter your password. In this scenario, it should be 123456. If you're OK, you'll enter the tag at the beginning of mysql.
[root@iZenarrdqnvpc4Z ~]# docker exec -it mysql /bin/bash root@7b96a24b92c2:/# mysql -u root -p #{123456} Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
If you want to change the root password, leave the root password blank and change the password.
# Leave the root password blank update user set authentication_string = '' where user = 'root' and host = 'localhost'; # Modify root password alter user root@'localhost' identified by 'Your password';
If you want to add users for others to use, you can do so.
# Add User create user dev@'%' identified by '123456'; # Authorize users grant Alter, Create, Create Temporary Tables, Create User, Create View, Delete, Drop, Event, Index, Insert, Lock Tables, Process, References, Reload, Select, Show Databases, Show View, Trigger, Update on *.* to dev@'%'; # Refresh Permissions flush privileges;
When you're done, you can connect remotely with the navticat premium tool...
We then created a.NET Core project to add EF packages related to MySql, where I encountered a problem where the following error occurred while I was using MySql.Data.EntityFrameworkCore entity porting and it is not known why.In.NET Core 3.0+BUG.I'll submit a question later.
System.TypeLoadException: Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.18.0, Culture=neutral,
So I used pomelo instead and found nothing unusual.Direct code first to dry.
public class MysqlDbContext : DbContext { public DbSet<Student> students { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { //base.OnConfiguring(optionsBuilder); string sqlConnection = "server=IP;uid=zaranet;pwd=123456;database=MyDemo"; optionsBuilder.UseMySql(sqlConnection); } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); } }
Then Add-Migration Init directly, and update..
PM> Add-Migration Init To undo this action, use Remove-Migration. PM> update-database Init
OK, open the navicat to see if it's successful.