https://wiki.mahara.org/index.php?title=System_Administrator%27s_Guide/Installing_Mahara/MySQL_and_Docker&feed=atom&action=historySystem Administrator's Guide/Installing Mahara/MySQL and Docker - Revision history2024-03-29T14:33:52ZRevision history for this page on the wikiMediaWiki 1.35.10https://wiki.mahara.org/index.php?title=System_Administrator%27s_Guide/Installing_Mahara/MySQL_and_Docker&diff=12373&oldid=prevGold: Adding a warning about not relying on dev config for prod environments.2021-10-20T03:29:20Z<p>Adding a warning about not relying on dev config for prod environments.</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 03:29, 20 October 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Note: This is intended to assist developers. If you are using this in a production environment it is expected that you will be rolling your own docker config for much higher security than this offers.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==tl;dr;==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==tl;dr;==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Docker can make things easy. It can also be fiddly. This worked for me.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Docker can make things easy. It can also be fiddly. This worked for me.</div></td></tr>
</table>Goldhttps://wiki.mahara.org/index.php?title=System_Administrator%27s_Guide/Installing_Mahara/MySQL_and_Docker&diff=12372&oldid=prevGold: Using MySQL in a docker container for development2021-10-20T03:22:53Z<p>Using MySQL in a docker container for development</p>
<p><b>New page</b></p><div>==tl;dr;==<br />
Docker can make things easy. It can also be fiddly. This worked for me.<br />
* Create the <code>docker-compose.yml</code> file<br />
* Update your <code>config.php</code> file<br />
* Spin up the container: <code>docker-compose run --service-ports -d db</code><br />
* Point a browser at your site.<br />
<br />
== The longer version ==<br />
=== Composer ===<br />
Add this to a <code>docker-compose.yml</code> file. This file can live anywhere and doesn't need to be in your checked out repo.<br />
<br />
version: '3'<br />
services:<br />
db:<br />
image: mysql<br />
command: --default-authentication-plugin=mysql_native_password<br />
restart: always<br />
environment:<br />
MYSQL_ROOT_PASSWORD: "password"<br />
MYSQL_USER: "maharauser"<br />
MYSQL_PASSWORD: "maharapassword"<br />
MYSQL_DATABASE: "mahara"<br />
ports:<br />
- 3323:3306<br />
volumes:<br />
- my-datavolume:/var/lib/mysql<br />
volumes:<br />
my-datavolume:<br />
<br />
====Spin up the container====<br />
<br />
docker-compose run --service-ports -d db<br />
<br />
====What is this doing?====<br />
We are creating a service (db) and a volume (for persistent storage).<br />
<br />
The <code>image</code> is the [https://hub.docker.com/_/mysql official image].<br />
<br />
The <code>environment</code> tells the container to set the <code>root</code> users password to "password" and to create another user that we will connect to the DB as. It also creates the "mahara" database.<br />
<br />
The <code>ports</code> map port 3323 on the host to port 3306 in the container. Set 3323 to anything you like if this is in conflict. This is preconfigured to a non-standard port just for ease of copy/paste. By default MySQL will be running on port 3306 and if you already have a different version running this will let you spin up your target version without conflicting with the existing one. Update the <code>image</code> with the version you want. The current value will fetch the <code>latest</code> version.<br />
<br />
The <code>volumes</code> tells docker to use persistent storage so your data will still be there after a restart of the container. The lack of settings on <code>my-datavolume</code> tells docker to pick how to manage this.<br />
<br />
===Mahara===<br />
====config.php====<br />
Add the following to your config.php file:<br />
$cfg->dbtype = 'mysql';<br />
$cfg->dbhost = '127.0.0.1';<br />
$cfg->dbport = 3323;<br />
$cfg->dbuser = 'maharauser';<br />
$cfg->dbpass = 'maharapassword';<br />
$cfg->dbname = 'mahara';<br />
<br />
It is important to use <code>127.0.0.1</code> as the host. If <code>mysql</code> receives <code>localhost</code> here it will try and connect via the local unix socket on the filesystem despite having a port set.<br />
<br />
===Gotchas===<br />
I have had issues with the <code>maharauser</code> not being able to create triggers and these are needed on site install. To get around this connect to the database as <code>root</code> and run the following:<br />
<br />
GRANT ALL PRIVILEGES ON *.* TO 'maharauser'@'%';<br />
<br />
THIS IS DANGEROUS... Do not do this anywhere except in a development environment. I could not figure out why, but running this on <code>mahara.*</code> was not enough.</div>Gold