Based in Honolulu, HI, 3leet5u is the software sketchbook of Tristan Madden.

Howto: Setup MySQL Server in LXD

LXD is very similar to Docker, but there are subtle differences that set them apart. LXD allows for the creation of operating-system-level containers as opposed to Docker’s application-level containers. LXD is also not just a typical virtualization technology because it offers a similar user experience to that of a virtual machine, while providing access to your real hardware for real performance. This “virtualization” of an entire Linux OS is useful for running persistent virtual apps for long periods of time. A database would be a solid application of this, so in this tutorial I will be creating a MySQL database inside of an LXC container.


 Step 1. Right-click on the desktop and open a new terminal. Type the command below to download the package lists from the repositories and "update" them to get information on the newest versions of packages and their dependencies.

Step 1. Right-click on the desktop and open a new terminal. Type the command below to download the package lists from the repositories and "update" them to get information on the newest versions of packages and their dependencies.

sudo apt update
 Step 2. Install the LXD package.

Step 2. Install the LXD package.

sudo apt install lxd
 Step 3: Initialize lxd. Upon typing this command, you will be prompted for your password and asked a series of questions regarding configuration. For our purposes, we can press ENTER repeatedly to accept the default values.

Step 3: Initialize lxd. Upon typing this command, you will be prompted for your password and asked a series of questions regarding configuration. For our purposes, we can press ENTER repeatedly to accept the default values.

sudo lxd init
 Step 4. Verify that LXD has been installed correctly by typing this command. The header of an empty table should print in the terminal.

Step 4. Verify that LXD has been installed correctly by typing this command. The header of an empty table should print in the terminal.

sudo lxc list
 Step 5. Create a container using an image of ubuntu-daily:16.04. Note that “c1” in this line is what I’ve chosen to name my container. You can replace this with whatever you like, or leave this argument out to have a name randomly generated for you.

Step 5. Create a container using an image of ubuntu-daily:16.04. Note that “c1” in this line is what I’ve chosen to name my container. You can replace this with whatever you like, or leave this argument out to have a name randomly generated for you.

sudo lxc launch ubuntu-daily:16.04 c1
 Step 6. Enter the command that lists your lxc containers again and verify that a container has been created and is running.

Step 6. Enter the command that lists your lxc containers again and verify that a container has been created and is running.

sudo lxc list
 Step 7. Now it’s time to step into this container. Open a bash terminal inside c1.

Step 7. Now it’s time to step into this container. Open a bash terminal inside c1.

sudo lxc exec c1 bash
 Step 8. Download and install MySQL Server.

Step 8. Download and install MySQL Server.

sudo apt-get install mysql-server
 Step 9. Upon installation, you’ll be prompted with this package configurator. Don’t forget to make note of the MySQL “root” login credentials you define here.

Step 9. Upon installation, you’ll be prompted with this package configurator. Don’t forget to make note of the MySQL “root” login credentials you define here.

 
 Step 10. Verify that mysql-server has installed properly.

Step 10. Verify that mysql-server has installed properly.

mysqladmin -u root -p status
 Step 11. Create the database ‘tutorialdb’ and the user ‘root’.

Step 11. Create the database ‘tutorialdb’ and the user ‘root’.

mysql -u root -p
CREATE DATABASE tutorialdb;
CREATE USER user@localhost IDENTIFIED BY 'tutor';
GRANT ALL PRIVILEGES ON tutorialdb.* TO user@localhost;
exit;
 Step 12. Exit the bash terminal.

Step 12. Exit the bash terminal.

exit

Writing to a file in Rust

Recamán's Sequence

Recamán's Sequence