Add basic DB guide articles

master
Nathan Steel 4 years ago
parent df4d70a598
commit ec8c40f001

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="Blog, articles, guide, mysql, mariadb, database">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
<link rel="stylesheet" type="text/css" href="/main.css">
<link rel="icon" type="image/png" href="/images/favicon.svg">
<title>Adminer Setup</title>
</head>
<body>
<header>
<h1>Adminer Setup</h1>
<hr/>
<nav>
<a href="/">home</a>
<a href="/equipment.html">equipment</a>
<a href="/projects.html">projects</a>
<a href="/blog/">blog</a>
<a href="/sitemap.html">misc</a>
<a href="/support.html">support</a>
</nav>
<hr/>
</header>
<main>
<section>
<p>Adminer is a simple front-end for your database server that can be access through the browser</p>
<h2>Pre-Requirements</h2>
<p>To run adminer, you'll need a webserver with php set up. Thankfully I'm a great guy, and have written about these topics before.</p>
<ul>
<li><a href="/blog/nginx-install.html">Nginx Webserver Setup</a></li>
<li>PHP setup for NGINX</li>
</ul>
<h2>Download the latest release</h2>
<p>This will download the latest release to your default web directory, this can be changed, by altering the path following <strong>-O</strong>.</p>
<pre><code>wget "http://www.adminer.org/latest.php" -O /var/www/html/adminer.php</code></pre>
<h2>Set permissions for your web server</h2>
<pre><code>chown -R www-data:www-data /var/www/html/adminer.php
chmod 755 /var/www/html/adminer.php</code></pre>
<h2>Access it</h2>
<p>Head to your <WEBSITE/IP>/adminer.php, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)</p>
<h2>Make it a directory, not a file</h2>
<p>Instead of accessing /adminer.php?<ARGUMENTS>, we can make it look like /adminer/<ARGUMENTS></p>
<pre><code>location /adminer/ {
root /var/www/html ;
try_files $uri $uri/ /adminer/index.php/$is_args$args ;
}</code></pre>
<h2>Password Protect</h2>
<p>An additional level of security, just in case. Using Htaccess, any file, or directory can be password protected</p>
<pre><code>sudo apt install apache2-utils
htpasswd -c /home/<USER>/.htpasswd admin</code></pre>
<h3>Add to location</h3>
<p>Add the location of the auth file to the adminer location block</p>
<pre><code>auth_basic "Adminer" ;
auth_basic_user_file /home/<USER>/.htpasswd ;</code></pre>
<p>They block should look like below</p>
<pre><code>location /adminer/ {
auth_basic "Adminer" ;
auth_basic_user_file /home/<USER>/.htpasswd ;
root /var/www/html ;
try_files $uri $uri/ /adminer/index.php/$is_args$args ;
}</code></pre>
</section>
</main>
<footer>
<hr/>
<p>Written by <a href="http://aney.co.uk" target="_blank" rel="noopener">@aney</a> with <a href="https://danluu.com/web-bloat/" target="_blank" rel="noopener">web bloat</a> in mind | <a href="https://github.com/Aney/website" target="_blank" rel="noopener">Source Code</a></p>
</footer>
</body>
</html>

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="Blog, articles, guide, mysql, mariadb, database">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
<link rel="stylesheet" type="text/css" href="/main.css">
<link rel="icon" type="image/png" href="/images/favicon.svg">
<title>Backup MySQL/MariaDB</title>
</head>
<body>
<header>
<h1>Backup MySQL/MariaDB</h1>
<hr/>
<nav>
<a href="/">home</a>
<a href="/equipment.html">equipment</a>
<a href="/projects.html">projects</a>
<a href="/blog/">blog</a>
<a href="/sitemap.html">misc</a>
<a href="/support.html">support</a>
</nav>
<hr/>
</header>
<main>
<section>
<p>A database if a huge part of many projects, services, and servers. If something goes wrong, data is wrongly updated/deleted there could be many problems. Thankfully we can make backups to make sure our data is safe.</p>
<h2>Manual Backup of a DB</h2>
<h2>Backup all DBs</h2>
<p>This follows on from the manual backup, so assumes you have the backup directory created</p>
<h2>Automate hourly backups</h2>
<h2>My backup script</h2>
<p>I follow the 3-2-1 backup approach, so I want to keep the files in multiple locations</p>
</section>
</main>
<footer>
<hr/>
<p>Written by <a href="http://aney.co.uk" target="_blank" rel="noopener">@aney</a> with <a href="https://danluu.com/web-bloat/" target="_blank" rel="noopener">web bloat</a> in mind | <a href="https://github.com/Aney/website" target="_blank" rel="noopener">Source Code</a></p>
</footer>
</body>
</html>

@ -50,23 +50,23 @@
<li><a href="/blog/setup-nginx-website.html">Setup an nginx website</a></li>
<li><a href="/blog/certbot-ssl.html">Add an SSL certificate w/Certbot</a></li>
<li><a href="/blog/nginx-web-optimisation.html">TODO: Nginx web optimisation</a></li>
<li>TODO:Add PHP to your webserver (optional)</li>
<li>TODO:<a href="/blog/add-php-to-nginx.html">(Optional) Add PHP to your webserver</a></li>
<li>TODO:Guide to web-development</li>
</ul>
<h2>MariaDB Database</h2>
<p>A database is a great tool to store, access, and filter data. Typically used alongside a website, or other services, but can be useful standalone if you know what you're doing</p>
<ul>
<li>TODO:Install mariaDB</li>
<li>TODO:SQL cheatsheet</li>
<li>TODO:Adminer install</li>
<li>TODO:Backup databases (optional)</li>
<li><a href="/blog/install-mysql-mariadb.html">Install mariaDB</a></li>
<li>TODO:<a href="/blog/sql-cheatsheet.html">SQL cheatsheet</a></li>
<li>TODO:<a href="/blog/adminer-setup.html">(Optional) Adminer setup</a></li>
<li>TODO:<a href="/blog/backup-mysql-mariadb.html">(Optional) Backup databases</a></li>
</ul>
<h2>Backup your server!</h2>
<p>Backups are super useful. If something breaks, or gets accidentally deleted you can always use a backup to get it back</p>
<ul>
<li>TODO:Setup rsync</li>
<li>TODO:<a href="/blog/backups-with-rsync.html">Setup rsync</a></li>
<li>TODO:Setup rdiff-backup</li>
<li>TODO:Setup backup cronjob(s)</li>
</ul>
@ -81,7 +81,7 @@
</ul>
<h2>Proxy services to port 80/433</h2>
<p>Many services you install will be accessible via the web, but will use a different ports. Proxying these allows access (and security) without the need to append a port to the server address</p>
<p>Many services you install will be accessible via the web, but will use different ports. Proxying these allows access (and security) without the need to append a port to the server address, and without directly allowing access to the service from outside the server.</p>
<h2>Additional services/potential guides</h2>
<p>Unless there is an anchor, these are all "TODO", and may just be omitted from this guide</p>
@ -101,6 +101,7 @@
<li>VPN</li>
<li>mailserver</li>
<li>cockpit for noob-friendly server management</li>
<li>Basic Homeserver for a web developer/designer</li>
</ul>
</section>

@ -38,6 +38,10 @@
<h2>2022</h2>
<ul>
<li><a href="/blog/sql-cheatsheet.html">SQL Cheatsheet</a> - 09/06/2022</li>
<li><a href="/blog/adminer-setup.html">Adminer Setup</a> - 09/06/2022</li>
<li><a href="/blog/backup-mysql-mariadb.html">Backing Up MySQL/MariaDB</a> - 09/06/2022</li>
<li><a href="/blog/install-mysql-mariadb.html">MySQL/MariaDB Setup Guide</a> - 09/06/2022</li>
<li><a href="/blog/nginx-web-optimisation.html">NGINX web optimisation</a> - 30/05/2022</li>
<li><a href="/blog/certbot-ssl.html">Setup SSL with Certbot</a> - 30/05/2022</li>
<li><a href="/blog/setup-nginx-website.html">How to setup an nginx website</a> - 30/05/2022</li>

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="Blog, articles, guide, mysql, mariadb, database">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
<link rel="stylesheet" type="text/css" href="/main.css">
<link rel="icon" type="image/png" href="/images/favicon.svg">
<title>MySQL (actually MariaDB) Setup Guide</title>
</head>
<body>
<header>
<h1>MySQL (actually MariaDB) Setup Guide</h1>
<hr/>
<nav>
<a href="/">home</a>
<a href="/equipment.html">equipment</a>
<a href="/projects.html">projects</a>
<a href="/blog/">blog</a>
<a href="/sitemap.html">misc</a>
<a href="/support.html">support</a>
</nav>
<hr/>
</header>
<main>
<section>
<p>MySQL is a well known free, open-source relational database service, and it's great. MariaDB is just MySQL (a fork of it), but better.</p>
<h2>Install MariaDB</h2>
<pre><code>sudo apt install mariadb-server</code></pre>
<h2>Secure Install/Setup</h2>
<pre><code>sudo mysql_secure_installation</code></pre>
<h2>Create Admin user</h2>
<pre><code>sudo mysql</code></pre>
<pre><code>GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;</code></pre>
<pre><code>FLUSH PRIVILEGES;</code></pre>
<pre><code>exit;</code></pre>
<h2>Test it works</h2>
<h2>(Optional) Make it easier to access on command line</h2>
<p>If you're working with a terminal, when calling <code>mysql</code> you'll need to enter a password each time. You can store the passwordwith a special .cnf file, making it faster to get into writing SQL.</p>
<p>Create/Edit the file with your editor of choice (mine's vim)</p>
<pre><code>vim ~/.my.cnf</code></pre>
<p>Add the following, with your credentials</p>
<pre><code>[mysql]
user=<USERNAME>
password=<PASSWORD></code></pre>
<p>The above can be used for mysqldump, mysqladmin, and others too, by replacing the <code>[mysql]</code> block</p>
</section>
</main>
<footer>
<hr/>
<p>Written by <a href="http://aney.co.uk" target="_blank" rel="noopener">@aney</a> with <a href="https://danluu.com/web-bloat/" target="_blank" rel="noopener">web bloat</a> in mind | <a href="https://github.com/Aney/website" target="_blank" rel="noopener">Source Code</a></p>
</footer>
</body>
</html>

@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Basic SQL cheatsheet for the commandline.">
<meta name="keywords" content="Blog, articles, guide, mysql, mariadb, database">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
<link rel="stylesheet" type="text/css" href="/main.css">
<link rel="icon" type="image/png" href="/images/favicon.svg">
<title>SQL Cheatsheet</title>
</head>
<body>
<header>
<h1>SQL Cheatsheet</h1>
<hr/>
<nav>
<a href="/">home</a>
<a href="/equipment.html">equipment</a>
<a href="/projects.html">projects</a>
<a href="/blog/">blog</a>
<a href="/sitemap.html">misc</a>
<a href="/support.html">support</a>
</nav>
<hr/>
</header>
<main>
<section>
<p>SQL is a great, simple to use language to manipulate data within a database. This cheatsheet is aimed at basic SQL for MySQL/MariaDB.</p>
<h2>Access on the command line</h2>
<pre><code>mysql -u <USERNAME> -p</code></pre>
<p>When prompted enter your password</p>
<h2>Database manipulation</h2>
<h3>Show databases</h3>
<pre><code>SHOW databases;</code></pre>
<h3>Create new databases</h3>
<pre><code>CREATE DATABASE IF NOT EXISTS <DATABASE>;</code></pre>
<h3>Enter into a database</h3>
<pre><code>USE DATABASE <DATABASE>;</code></pre>
<p>or just</p>
<pre><code>USE <DATABASE>;</code></pre>
<h2>Table manipulation</h2>
<p>Once you've got a database selected, you can play with tables</p>
<h3>Create</h3>
<h3>Read</h3>
<h3>Update</h3>
<h3>Delete</h3>
<h2>Data manipulation</h2>
<p>Most of your SQL life will be CRUDing (Create, Read, Update, Delete) data. So I'll cover the basics here</p>
<h3>Create</h3>
<h3>Read</h3>
<h3>Update</h3>
<h3>Delete</h3>
<h2>Create additional users</h2>
</section>
</main>
<footer>
<hr/>
<p>Written by <a href="http://aney.co.uk" target="_blank" rel="noopener">@aney</a> with <a href="https://danluu.com/web-bloat/" target="_blank" rel="noopener">web bloat</a> in mind | <a href="https://github.com/Aney/website" target="_blank" rel="noopener">Source Code</a></p>
</footer>
</body>
</html>
Loading…
Cancel
Save