Cause is lazy
I am a Java programmer, and I ca n’t do without basic services such as redis, mysql, and kafka when writing code at home. The usual practice is to turn on the computer, start redis, mysql, and kafka, and then shut down the computer after use. ? You scolded right ...)
Not the first toss
I have tossed the Synology DS218 + at home before, installed maven private server nexus3, address: "Synology DS218 + do maven private service (nexus3)"
Synology DS218 +
There is a Synology DS218 + at home. For a long time, it has been turned on for 24 hours to serve the whole family. If you can install mysql here, it seems that the trouble in front is gone;
- The picture below is what DS218 + just bought. Two NAS hard drives have been in stable service:
- The following picture is a memory stick purchased online. Now there are a total of 2 + 8 = 10G memory, and enough memory is the guts to dare toss:
- It is said that the original 2G memory stick can be replaced by disassembling the machine, and two 8G memory sticks can be installed. Currently, it is not used for the time being. I need to exercise restraint ...
Ideas
In fact, the operation is very simple: Synology has a docker service, and docker can be used to deploy mysql. Therefore, this article is actually the basic operation record of Synology docker.
- Container port
- Container data volume
- File Permissions
- Login container operation
Environmental information
- Synology System: DSM 6.2.2-24922 Update 4
- Mysql:5.7.29
Ready to work
- First prepare a local directory for the MySQL container, otherwise, once the container has a problem, the MySQL data will not be found.
- As shown below, in File Station, create a new folder named mysql under the docker directory:
- You must also grant permissions to this directory, otherwise the container cannot write data, as shown in the figure below, right-click and select properties on the menu :
- As shown below, I have released all permissions here for simplicity and ease:
- The operations in the red box as shown below:
- The preparation work has been completed, and the formal operation can be started;
operating
- Enter the Synology Management page
- Enter the docker application, search the mysql image, and operate the numerical sequence as shown in the figure below, you can start downloading the image:
- After the image is downloaded, operate in the numerical order as shown in the figure below, and enter the page to start the container:
- Give the container a suitable name, and then click Advanced Settings :
- Select the Tab page of the volume and click Add Folder :
- Select the mysql folder we just created:
- The loading path refers to the path in the container, write / var / lib / mysql :
- Next, set the port, as shown below, change the local port corresponding to 3306 from 3306 automatically :
- Finally, on the Tab page of the environment , add the password setting of the MySQL root account, as shown below, the name MYSQL_ROOT_PASSWORD , the value 123456 , after the operation is complete, click the apply button in the lower right corner to complete the setting:
- Run the container after checking the wizard , click the application in the lower right corner to start creating the container:
verification
Let's verify that MySQL is available:
- Double-click the position in the red box below:
- In the pop-up page, continue to double-click the position in the red box below:
- As shown below, you can execute a shell command in the namepace of the MySQL container:
- A window pops up for you to enter the command, please enter / bin / bash :
- As shown below, enter the container:
- Execute the command mysql -uroot -p123456 , you can enter the MySQL command mode, as shown below, the operation is normal:
- Try to connect remotely. After all, other machines will connect by IP address in the future. I used a Macbook Pro, installed MySQL Workbench , configured Synology IP address and port 3306 , account is root , password 123456 , the connection is normal, as shown below: So
far, Synology DS218 + has successfully deployed MySQL. In the future, database services will be available at any time without any additional cost.