% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math} % this also loads fontspec
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
  % xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
\hypersetup{
  pdftitle={mySQL},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}

\title{mySQL}
\author{}
\date{}

\begin{document}
\maketitle

\hypertarget{mysql}{%
\section{mySQL}\label{mysql}}

\hypertarget{mysql-1}{%
\section{mySQL}\label{mysql-1}}

mySQL database information.

.. contents::

\hypertarget{full-text-minimum-word-length}{%
\subsection{Full-Text Minimum word
length}\label{full-text-minimum-word-length}}

Full-text minimum length default is set to 4. To adjust this setting,
edit /etc/mysql/my.cnf and add the following line under {[}mysqld{]}::

ft\_min\_word\_len = 3

Next we need to restart mysql::

\$ sudo service mysql restart

Last repair the full-text index on the table::

mysql\textgreater{} REPAIR TABLE table\_name QUICK

\hypertarget{create-database}{%
\subsection{Create database}\label{create-database}}

log into mysql as root:

.. code-block:: mysql

CREATE DATABASE lostquery

Or optionally make Character set utf8 for unicode support

.. code-block:: mysql

CREATE DATABASE lostquery DEFAULT CHARACTER SET utf8 DEFAULT COLLATE
utf8\_unicode\_ci;

\hypertarget{create-a-user}{%
\subsection{Create a user}\label{create-a-user}}

The following command will create a user with a password and grant all
privileges to the user on a particular database:

.. code-block:: mysql

GRANT ALL PRIVILEGES ON lostquery.* TO username@localhost IDENTIFIED BY
`passw0rd' WITH GRANT OPTION

\hypertarget{restore-database}{%
\subsection{Restore database}\label{restore-database}}

The following command with restore a database from a backup .sql file

.. code-block:: bash

mysql -u username -p lostquery \textless{}
lostquery-backup-2012-12-10.sql

\hypertarget{drop-user}{%
\subsection{Drop user}\label{drop-user}}

.. code-block:: sql

DROP USER username@localhost

\hypertarget{drop-database}{%
\subsection{Drop database}\label{drop-database}}

.. code-block:: sql

DROP DATABASE databasename

\hypertarget{show-the-mysql-processlist-or-list-of-currently-running-queries}{%
\subsection{Show the MySQL processlist or list of currently running
queries}\label{show-the-mysql-processlist-or-list-of-currently-running-queries}}

.. code-block:: mysql

mysqladmin -u root -p processlist

\hypertarget{create-a-read-only-user-for-backing-up-databases}{%
\subsection{Create a read only user for backing up
databases}\label{create-a-read-only-user-for-backing-up-databases}}

.. code-block:: mysql

GRANT SELECT, LOCK TABLES ON \emph{.} TO backup\_user@localhost;

\hypertarget{backup-all-databases-into-separate-files}{%
\subsection{Backup all databases into separate
files}\label{backup-all-databases-into-separate-files}}

.. code-block:: bash

\#!/bin/bash

USER=``backup\_user'' PASSWORD=``\,'' TODAY=\texttt{date\ +\%Y-\%m-\%d}
OUTPUTDIR=``/backup/db/\$TODAY'' MYSQLDUMP=``/usr/bin/mysqldump''
MYSQL=``/usr/bin/mysql'' GZIP=``bin/gzip''

mkdir \$OUTPUTDIR

\# get a list of databases
databases=\texttt{\$MYSQL\ -\/-user=\$USER\ -\/-password=\$PASSWORD\ \textbackslash{}\ \ \ -e\ "SHOW\ DATABASES;"\ \textbar{}\ tr\ -d\ "\textbar{}\ "\ \textbar{}\ grep\ -v\ Database}

\# dump each database in turn for db in \$databases; do
\(MYSQLDUMP --force --opt --user=\)USER --password=\$PASSWORD\\
--databases \(db > "\)OUTPUTDIR/\$db.sql'' done

\# compress all of the files \$GZIP \$OUTPUTDIR/*

Reference:
\texttt{Backup\ multiple\ mysql\ databases\ into\ separate\ files\ \textless{}http://www.snowfrog.net/2005/11/16/backup-multiple-databases-into-separate-files/\textgreater{}}\_

\end{document}
