Running MySQL from a ZIP Archive

A Quick Guide for Windows Users.

This quick guide will teach you how to configure and run a MySQL server from a noinstall ZIP archive on Windows.


Reference


https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html


Download the ZIP Archive


Firstly, download the MySQL Community Server 8.0.15 ZIP archive and extract it to the desired location for your installation (e.g. C:\Users\user.name\AppData\Local\Programs\mysql), then create the following directories:

  • MySQL Database data files: C:\Users\user.name\AppData\Local\Programs\mysql\db
  • MySQL Log files:  C:\Users\user.name\AppData\Local\Programs\mysql\logs

Create the configuration file


You'll need to create the required configuration file at C:\Users\user.name\AppData\Local\Programs\mysql\config.ini:


[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# set basedir to your installation path
basedir = "C:\\Users\\christopher.rowles\\AppData\\Local\\Programs\\mysql\\mysql-8.0.15-winx64"
# set datadir to the location of your data directory
datadir = "C:\\Users\\christopher.rowles\\AppData\\Local\\Programs\\mysql\\db"
# The port number to use when listening for TCP/IP connections. On Unix and Unix-like systems, the port number must be
# 1024 or higher unless the server is started by the root system user.
port = "3306"
# Log errors and startup messages to this file.
log-error = "C:\\Users\\christopher.rowles\\AppData\\Local\\Programs\\mysql\\logs\\log.err"

[mysqladmin]
user = "root"
port = "3306"
    

Initialise MySQL


You'll now need to initialise the MySQL database files:

  1. Open Windows command prompt (Hit Win + R, then type 'cmd' and press enter).
  2. Type the following command to initialise the files:
    "C:\Users\user.name\AppData\Local\Programs\mysql\mysql-8.0.15-winx64\bin\mysqld.exe" --defaults-file="C:\Users\user.name\AppData\Local\Programs\mysql\config.ini" --initialize-insecure --console

The command above should:

  • Create database files in the location specified in config.ini.
  • Initialise the root user with no password.
  • Log any errors to the current console.

Configure startup/shutdown scripts


Finally, create two batch scripts to manage your MySQL instance:


mysql-start.cmd:

"C:\Users\user.name\AppData\Local\Programs\mysql\mysql-8.0.15-winx64\bin\mysqld.exe" --defaults-file="C:\Users\christopher.rowles\AppData\Local\Programs\mysql\config.ini"

mysql-shutdown.cmd:

"C:\Users\user.name\AppData\Local\Programs\mysql\mysql-8.0.15-winx64\bin\mysqladmin.exe" --defaults-file="C:\Users\christopher.rowles\AppData\Local\Programs\mysql\config.ini" shutdown

These scripts can be invoked directly to start/stop your MySQL instance.


Finished


You should now have a functioning MySQL instance!


Please be aware that this guide does not provide a secure, production-ready configuration for your MySQL instance, it is only intended for development purposes.


Extra Steps


This guide showed you how to configure a basic MySQL instance with no password required for the root user, if you would like to configure the root user to use a password, follow these extra steps:

  1. Alter your config.ini file and include the following at the bottom of the [mysqld] section:
    default_authentication_plugin=mysql_native_password
  2. Execute the following query, replacing 'password' with your chosen password:
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
  3. Restart MySQL.

I hope this guide helps! If you have any questions, please feel free to contact me@rowles.ch :)



View

Setting up a Mail Server in EC2

A Quick Guide.

This guide will teach you how to configure an email server for your domain, using an Amazon EC2 instance


Requirements


  • A domain name, with control over the DNS records
  • An AWS account
  • Familiarity with Linux and the AWS ecosystem

Create a new EC2 Instance


Firstly you'll want to setup a dedicated host for sending and receiving email. I would recommend configuring a new instance with the following, which is within free-tier limits:

  • Amazon Linux 2 AMI (64-bit)
  • Type t2.micro
  • Default instance details
  • Default storage details
  • No tags
  • A new security group (details are directly below)

Your mail server will listen for incoming mail via SMTP, so you should create a new dedicated security group and open inbound TCP port 25 so that you will be able to receive mail.

Finally, allocate an Elastic IP address and associate it to the newly created instance. This will provide a static IP address for your mail server.


Add DNS Records


Next, youll need to create the required DNS records in order for emails to be properly routed through your host.

Create an A record for your host from mail.domain.tld to your new Elastic IP address

Then create an MX record for domain.tld to 10 mail.domain.tld


NOTE: Anti-spam software will require that any server sending mail has a valid reverse DNS record. You will need to Contact AWS to create this record.


Configure Host


Now we'll need to SSH into the new instance to configure it for mail.

Firstly, ensure your host knows its own name:

$ /etc/hosts
127.0.0.1    mail.domain.tld localhost localhost.localdomain
    
$ /etc/sysconfig/network
HOSTNAME=mail.domain.tld
    

Configure Postfix


We'll be using postfix to send and receive our mail. If it isn't already installed, please install it now:

$ sudo yum install -y postfix
    

The minimum changes we'll need to make are listed below:

$ /etc/postfix/main.cf
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = domain.tld
myhostname = mail.domain.tld
mynetworks_style = host
myorigin = $mydomain
    

After the required changes have been made, start postfix and enable it to start on reboot:

$ sudo systemctl start postfix
$ sudo systemctl enable postfix
    

Finished


You should now have a functioning mail server! You can test this by installing a mail user agent such as mailx:

$ sudo yum install -y mailx
    

To test sending mail:

$ echo "Hello World" | mail -s subject existing-email@existing-domain.tld
    

To test receiving mail:

$ mail
Heirloom Mail version 12.5. Type ? for help.
"/var/spool/mail/ec2-user": 1 messages 1 new
...
...
    

I hope this quick guide helps! If you have any questions, please feel free to contact me@rowles.ch :)



View