<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=MariaDB_Administration_-_Part1</id>
	<title>MariaDB Administration - Part1 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=MariaDB_Administration_-_Part1"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=MariaDB_Administration_-_Part1&amp;action=history"/>
	<updated>2026-05-13T23:41:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=MariaDB_Administration_-_Part1&amp;diff=23438&amp;oldid=prev</id>
		<title>Bernard Szlachta: /* Local (non system) Variables ⌘ */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=MariaDB_Administration_-_Part1&amp;diff=23438&amp;oldid=prev"/>
		<updated>2014-10-22T11:10:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Local (non system) Variables ⌘&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cat|MySQL|010}}&lt;br /&gt;
{{Cat|MariaDB|010}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;slideshow style=&amp;quot;nobleprog&amp;quot; headingmark=&amp;quot;⌘&amp;quot; incmark=&amp;quot;…&amp;quot; scaled=&amp;quot;true&amp;quot; font=&amp;quot;Trebuchet MS&amp;quot; &amp;gt;&lt;br /&gt;
;title: MariaDB Administration Part 1&lt;br /&gt;
;author: Bernard Szlachta (NobleProg Ltd)&lt;br /&gt;
&amp;lt;/slideshow&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= MODULE 1 =&lt;br /&gt;
== MySQL and MariaDB history  ⌘==&lt;br /&gt;
* MySQL founded 1995&lt;br /&gt;
* acquired by Sun Microsystems 2008&lt;br /&gt;
* now owned by Oracle Corporation since 2009&lt;br /&gt;
* soon after MariaDB started by original authors of MySQL&lt;br /&gt;
&lt;br /&gt;
== Release Background ⌘==&lt;br /&gt;
* 1994 - MySQL by Michael (Monty) Widenius and David Axmark&lt;br /&gt;
* First internal release on 23 May 1995&lt;br /&gt;
* Windows version was released on 8 January 1998 for Windows 95 and NT&lt;br /&gt;
* Version 3.23 January 2001&lt;br /&gt;
* Version 4.0 March 2003 (unions)&lt;br /&gt;
* Version 4.1 October 2004 (R-trees and B-trees, subqueries, prepared statements)&lt;br /&gt;
* Version 5.0 October 2005 (cursors, stored procedures, triggers, views)&lt;br /&gt;
* Sun Microsystems acquired MySQL AB on 26 February 2008.&lt;br /&gt;
* Version 5.1 November 2008 (event scheduler, partitioning, plugin API, row-based replication, server log tables)&lt;br /&gt;
* MySQL 5.1 and 6.0 showed poor performance when used for data warehousing — partly due to its inability to utilize multiple CPU cores for processing a single query.[26]&lt;br /&gt;
* MariaDB initial release - 22 January 2009&lt;br /&gt;
* Oracle acquired Sun Microsystems on 27 January 2010. Oracle and Sun&lt;br /&gt;
* December 2012 - MariaDB foundation has been established&lt;br /&gt;
* On October 1, 2014, SkySQL Corporation Ab changed its name to MariaDB Corporation Ab&lt;br /&gt;
&lt;br /&gt;
== MariaDB Server Installation ⌘==&lt;br /&gt;
* Install the server discussing different options&lt;br /&gt;
* GUI Tools Instalation&lt;br /&gt;
* Quick Overview on GUI Tools&lt;br /&gt;
&lt;br /&gt;
== Installing in Ubuntu ⌘==&lt;br /&gt;
* https://downloads.mariadb.org/mariadb/repositories/#mirror=coreix&lt;br /&gt;
&lt;br /&gt;
== Starting and stopping server ⌘==&lt;br /&gt;
Linux&lt;br /&gt;
 sudo service mysql start&lt;br /&gt;
 sudo service mysql stop&lt;br /&gt;
&lt;br /&gt;
Windows (as a serverice)&lt;br /&gt;
 net start mysql&lt;br /&gt;
&lt;br /&gt;
MariaDB 10.0 starting from command line&lt;br /&gt;
 mysqld --console&lt;br /&gt;
&lt;br /&gt;
== Installing on Windows⌘==&lt;br /&gt;
* https://downloads.mariadb.org/&lt;br /&gt;
* Follow installer steps&lt;br /&gt;
&lt;br /&gt;
== Hardware and MariaDB ⌘==&lt;br /&gt;
* A lot of MariaDB features has been created when memory and CPU power was expensive and not flexible&lt;br /&gt;
* I try to avoid things specific to MariaDB&lt;br /&gt;
* For example, the physical hard drive failure is not an issue with cloud computing&lt;br /&gt;
* As for partitioning, it can be handle by the storage itself (S3, RAID, etc...) Usually you can buy it very cheaply&lt;br /&gt;
* SSD drives are the most disruptive technology&lt;br /&gt;
* Optimization vs hardware, it is usually cheaper to buy extra resources, more complicated optimization is the last resort&lt;br /&gt;
&lt;br /&gt;
== MySQL and Platform ⌘==&lt;br /&gt;
* Using Debian, Ubuntu or other Linux distrubtion, you don&amp;#039;t have to do upgrade and huge chunk of maintenance work yourself&lt;br /&gt;
* Windows 32bit memroy limitation is 3.2 GB, around 60% of optimization problems was related to this limitation&lt;br /&gt;
* Changing default behaviour means that the changes must be documented or automated during the application installation process. This can depend on the platform as well.&lt;br /&gt;
* The most suitable platforms are Linux and Windows. Other systems (despite vendors promises) do not have so big community support&lt;br /&gt;
* Choosing platform is important and does effect the effort needed to maintain the system&lt;br /&gt;
&lt;br /&gt;
== MariaDB and OS ⌘==&lt;br /&gt;
* Some configurations options of the server depend of the platform.&lt;br /&gt;
* Using frameworks and database separation libraries (persistence), like Spring, Drupal, etc... can avoid common mistakes&lt;br /&gt;
* If your database is too big and you &amp;quot;think&amp;quot; you need new features, look at the data from &amp;quot;business&amp;quot; perspective. &lt;br /&gt;
** Is it redundant? &lt;br /&gt;
** Does it has to be stored in the main database?&lt;br /&gt;
** Can we delete or move old data?&lt;br /&gt;
* Usually good data design and cleansing process solves 80% of cases I encountered. Using partitioning, replication or cluster is much more expensive compare to business like solution.&lt;br /&gt;
* Smart SOA allows you to avoid big monolithic applications with huge databases&lt;br /&gt;
&lt;br /&gt;
== MariaDB Storage Engines ⌘==&lt;br /&gt;
* MariaDB supports several storage engines that act as handlers for different table types.&lt;br /&gt;
* Some table are transaction-safe and nontransaction-safe&lt;br /&gt;
  SHOW ENGINES; shows supported storage engine&lt;br /&gt;
&lt;br /&gt;
== MySQL Storage Engines ⌘==&lt;br /&gt;
InnoDB/XtraDB&lt;br /&gt;
* A transaction-safe (ACID compliant)&lt;br /&gt;
* Has commit, rollback, and crash-recovery capabilities&lt;br /&gt;
* InnoDB row-level locking and Oracle-style consistent nonlocking reads&lt;br /&gt;
* Good for increase multi-user concurrency and performance&lt;br /&gt;
* InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys&lt;br /&gt;
* Supports FOREIGN KEY referential-integrity constraints&lt;br /&gt;
MyISAM&lt;br /&gt;
* Mainly for web and data warehouses&lt;br /&gt;
* Doesn’t support transactions and foreign keys&lt;br /&gt;
Memory (HEAP)&lt;br /&gt;
* Stores all data in RAM for extremely fast access in environments that require quick lookups of reference and other like data&lt;br /&gt;
Merge&lt;br /&gt;
* Logically groups a series of identical MyISAM tables and reference them as one object&lt;br /&gt;
* Good for VLDB environments such as data warehousing&lt;br /&gt;
Archive&lt;br /&gt;
* Provides the perfect solution for storing and retrieving large amounts of seldom-referenced historical, archived, or security audit information.&lt;br /&gt;
CSV&lt;br /&gt;
* Stores data in text files using comma-separated values format.&lt;br /&gt;
* Easily exchange data between other software and applications that can import and export in CSV format&lt;br /&gt;
* Use to store log files&lt;br /&gt;
Blackhole&lt;br /&gt;
* accepts but does not store data and retrievals always return an empty set&lt;br /&gt;
* Can be used in distributed database design where data is automatically replicated, but not stored locally.&lt;br /&gt;
More:&lt;br /&gt;
* https://mariadb.com/kb/en/mariadb/documentation/storage-engines/&lt;br /&gt;
&lt;br /&gt;
== MyISAM vs. InnoDB ⌘==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MyISAM &lt;br /&gt;
! InnoDB&lt;br /&gt;
|-&lt;br /&gt;
| Few DML operations&lt;br /&gt;
| OLTP with a lot of DML&lt;br /&gt;
|-&lt;br /&gt;
| Very fast for selects&lt;br /&gt;
| Slower for selects&lt;br /&gt;
|-&lt;br /&gt;
| Some data can get corrupted&lt;br /&gt;
| Good crash-recovery facility&lt;br /&gt;
|-&lt;br /&gt;
| Cannot be a MASTER server in replication, but can be a SLAVE&lt;br /&gt;
| Perfect for MASTER server in replication&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| Supports FOREIGN KEY&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| Binary logs&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| Point-in-time recovery&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MyISAM vs. InnoDB ⌘==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Feature !! MyISAM !! innoDB&lt;br /&gt;
|-&lt;br /&gt;
| Storage limits || 256TB || 64TB&lt;br /&gt;
|-&lt;br /&gt;
| Transactions || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Locking granularity || Table || Row&lt;br /&gt;
|-&lt;br /&gt;
| MVCC || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Geospatial indexing support || Yes || No&lt;br /&gt;
|-&lt;br /&gt;
| Full-text search indexes || Yes || No&lt;br /&gt;
|-&lt;br /&gt;
| Clustered indexes || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Data caches || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Cluster database support || No || No&lt;br /&gt;
|-&lt;br /&gt;
| Foreign key support || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Point-in-time recovery || No || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MariaDB Server Files and Scripts ⌘==&lt;br /&gt;
* MariaDB Programs&lt;br /&gt;
* Server Programms&lt;br /&gt;
* Client Programms&lt;br /&gt;
* GUI and other tools&lt;br /&gt;
&lt;br /&gt;
== MariaDB Programs ⌘==&lt;br /&gt;
* SERVER&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;mysqld&amp;#039;&amp;#039;&amp;#039; - the MySQL server&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;mysqld_safe&amp;#039;&amp;#039;&amp;#039; - a script which starts mysqld, recommended of starting the server&lt;br /&gt;
*** restarts the server when an error occur&lt;br /&gt;
*** logs run-time and failure information&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;mysqld_multi&amp;#039;&amp;#039;&amp;#039; - script that can start or stop multiple servers installed on the&lt;br /&gt;
system (different ports or sockets)&lt;br /&gt;
* CLIENT&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;mysql&amp;#039;&amp;#039;&amp;#039; - a command line client&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;mysqladmin&amp;#039;&amp;#039;&amp;#039; - administrative operations&lt;br /&gt;
*** relading the grant tables&lt;br /&gt;
*** creating/dropping database&lt;br /&gt;
*** flushing tables to disk&lt;br /&gt;
*** managing log files&lt;br /&gt;
*** shutdown the database&lt;br /&gt;
&lt;br /&gt;
== MariaDB Programs ⌘==&lt;br /&gt;
* MariaDB Database&lt;br /&gt;
** Visual database design application&lt;br /&gt;
* MariaDB Galera Cluster&lt;br /&gt;
** Database Cluster&lt;br /&gt;
* Client Libraries (Java/C, etc..) and ODBC Drivers&lt;br /&gt;
** Connectivity from applications&lt;br /&gt;
* Graphical Clients&lt;br /&gt;
** https://mariadb.com/kb/en/mariadb/documentation/clients-and-utilities/graphical-clients/&lt;br /&gt;
&lt;br /&gt;
== Ways of starting a server ⌘==&lt;br /&gt;
* Windows or Unix service&lt;br /&gt;
** sudo /etc/init.d/mysql start&lt;br /&gt;
* Mysqld_safe&lt;br /&gt;
** sudo mysqld_safe&lt;br /&gt;
* Command line mysqld (Unix)&lt;br /&gt;
 sudo mysqld&lt;br /&gt;
* Command line Windows (MariaDB)&lt;br /&gt;
 mysqld --console&lt;br /&gt;
&lt;br /&gt;
== Stopping MariaDB Server ⌘==&lt;br /&gt;
* Windows/Unix Service&lt;br /&gt;
** sudo /etc/init.d/mysql stop&lt;br /&gt;
** sudo service mysql stop&lt;br /&gt;
** net stop mysql (Windows)&lt;br /&gt;
* mysqladmin&lt;br /&gt;
** mysqladmin -u root -p shutdown&lt;br /&gt;
&lt;br /&gt;
== Changing Forgotten Password ⌘==&lt;br /&gt;
* Run &lt;br /&gt;
 mysqld --skip-grant-tables  --skip-networking &lt;br /&gt;
** This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases&lt;br /&gt;
* Executing&lt;br /&gt;
** mysqladmin flush-privileges or&lt;br /&gt;
** mysqladmin reload or&lt;br /&gt;
** FLUSH PRIVILEGES&lt;br /&gt;
* Change your password&lt;br /&gt;
** set password for root@localhost = password(&amp;#039;asdfasdf&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
== Changing Forgotten Password ⌘==&lt;br /&gt;
&lt;br /&gt;
* In order to prevent external connections accessing the databases you can change the port and the bind interface&lt;br /&gt;
 mysqld --bind-address=127.0.0.1 --port 333 --skip-granttables&lt;br /&gt;
* You can connect to the database with the command below&lt;br /&gt;
 mysql -P 333 -h 127.0.0.1&lt;br /&gt;
&lt;br /&gt;
== Running Scripts ⌘==&lt;br /&gt;
* download [[File:Tables.sql]]&lt;br /&gt;
From MySQL prompt&lt;br /&gt;
 use test&lt;br /&gt;
 source filename&lt;br /&gt;
From Command Line&lt;br /&gt;
 cat filename | mysql (Unix only)&lt;br /&gt;
Windows&lt;br /&gt;
 type c:\Tables.sql | mysql -u root -pasdf test&lt;br /&gt;
 mysql -u root -pasdf test &amp;lt; c:\Tables.sql&lt;br /&gt;
* GUI Tools&lt;br /&gt;
Running a SQL statement from shell&lt;br /&gt;
* echo select * from EMP | mysql test;&lt;br /&gt;
Saving errors to a file&lt;br /&gt;
* mysql --force &amp;lt; tables.sql 2&amp;gt; error.log&lt;br /&gt;
&lt;br /&gt;
== Using Client Tools ⌘==&lt;br /&gt;
* System Variables&lt;br /&gt;
** Windows&lt;br /&gt;
 SET USER=your_name&lt;br /&gt;
** Unix the currently logged in user in the system&lt;br /&gt;
 MYSQL_TCP_PORT=3306; export MYSQL_TCP_PORT&lt;br /&gt;
 mysql –u user –ppassword –h host database&lt;br /&gt;
* Config file (my.ini or /etc/mysql/my.cnf)&lt;br /&gt;
 [client]&lt;br /&gt;
 host=host_name&lt;br /&gt;
 user=user_name&lt;br /&gt;
 password=your_pass&lt;br /&gt;
&lt;br /&gt;
= MODULE 2 =&lt;br /&gt;
== MariaDB Server Configuration ⌘==&lt;br /&gt;
* mysqld Options&lt;br /&gt;
* Server System Variables&lt;br /&gt;
* Dynamic System Variables&lt;br /&gt;
* Server Status Variables&lt;br /&gt;
* The Server SQL Mode&lt;br /&gt;
* Shutdown Process&lt;br /&gt;
&lt;br /&gt;
== mysqld server options ⌘==&lt;br /&gt;
* MariaDB Server manages access to the MySQL data directory that contains databases and tables.&lt;br /&gt;
* For a complete list of options, run this command:&lt;br /&gt;
 mysqld --verbose --help&lt;br /&gt;
&lt;br /&gt;
== Passing options to MariaDB server ⌘==&lt;br /&gt;
* System variable&lt;br /&gt;
* Cmd-Line&lt;br /&gt;
* Option file&lt;br /&gt;
* System Var&lt;br /&gt;
* Status Var [session or global or both]&lt;br /&gt;
&lt;br /&gt;
== Checking variable value ⌘==&lt;br /&gt;
 mysql&amp;gt; show variables like &amp;#039;%query_cache%&amp;#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Variable_name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| have_query_cache || YES&lt;br /&gt;
|-&lt;br /&gt;
| query_cache_limit || 1048576&lt;br /&gt;
|-&lt;br /&gt;
| query_cache_min_res_unit || 4096&lt;br /&gt;
|-&lt;br /&gt;
| query_cache_size || 0&lt;br /&gt;
|-&lt;br /&gt;
| query_cache_type || ON&lt;br /&gt;
|-&lt;br /&gt;
| query_cache_wlock_invalidate || OFF&lt;br /&gt;
|}&lt;br /&gt;
6 rows in set (0.01 sec)&lt;br /&gt;
&lt;br /&gt;
== Parameters Formats ⌘==&lt;br /&gt;
* Command Line Format &lt;br /&gt;
 mysqld --sync-binlog=#&lt;br /&gt;
* Config File Format &lt;br /&gt;
 sync-binlog&lt;br /&gt;
* Option Sets Variable Yes,&lt;br /&gt;
 sync_binlog&lt;br /&gt;
* Variable Name&lt;br /&gt;
 sync_binlog&lt;br /&gt;
* Variable Scope Global&lt;br /&gt;
* Dynamic Variable&lt;br /&gt;
* Permitted Values&lt;br /&gt;
 Type numeric&lt;br /&gt;
 Default 0&lt;br /&gt;
 Range 0-4294967295&lt;br /&gt;
&lt;br /&gt;
== Restricting maximum value of a variable ⌘==&lt;br /&gt;
 mysqld --maximum-var_name=value&lt;br /&gt;
&lt;br /&gt;
== Server Options for Loading Plugins ==&lt;br /&gt;
* Enable the plugin&lt;br /&gt;
 --plugin_name[=ON]&lt;br /&gt;
 --plugin_name=1&lt;br /&gt;
 --enable-plugin_name&lt;br /&gt;
If plugin initialization fails, start the server anyway, but with the plugin disabled&lt;br /&gt;
 --plugin_name=FORCE&lt;br /&gt;
If plugin initialization fails, do not start the server&lt;br /&gt;
* Disable plugin&lt;br /&gt;
 --plugin_name=OFF&lt;br /&gt;
 --skip-plugin_name&lt;br /&gt;
 --pluin_name=0&lt;br /&gt;
 --disable-plugin_name&lt;br /&gt;
&lt;br /&gt;
== System Variables ⌘==&lt;br /&gt;
* System variables&lt;br /&gt;
** indicate how the server is configured&lt;br /&gt;
** accessible via &amp;quot;Select @@variablename&amp;quot; &lt;br /&gt;
* Session Variables&lt;br /&gt;
** cannot be set at server startup&lt;br /&gt;
* Status Variable&lt;br /&gt;
 show status;&lt;br /&gt;
* Scope of the variable&lt;br /&gt;
** GLOBAL &lt;br /&gt;
** SESSION&lt;br /&gt;
&lt;br /&gt;
== Session System Variables ⌘==&lt;br /&gt;
* exist only as session variables&lt;br /&gt;
* these cannot be set at server startup &lt;br /&gt;
* can be assigned values at runtime using the SET statement (except for those that are read only)&lt;br /&gt;
* Most of them are not displayed by SHOW VARIABLES, but you can obtain their values using SELECT.&lt;br /&gt;
 E.g. autocommit&lt;br /&gt;
 select @@autocommit&lt;br /&gt;
 MariaDB [(none)]&amp;gt; set SESSION autocommit=OFF;&lt;br /&gt;
 MariaDB [(none)]&amp;gt; SELECT  @@GLOBAL.autocommit;&lt;br /&gt;
 +---------------------+&lt;br /&gt;
 | @@GLOBAL.autocommit |&lt;br /&gt;
 +---------------------+&lt;br /&gt;
 |                   1 |&lt;br /&gt;
 +---------------------+&lt;br /&gt;
 1 row in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
 MariaDB [(none)]&amp;gt; SELECT  @@SESSION.autocommit;&lt;br /&gt;
 +----------------------+&lt;br /&gt;
 | @@SESSION.autocommit |&lt;br /&gt;
 +----------------------+&lt;br /&gt;
 |                    0 |&lt;br /&gt;
 +----------------------+&lt;br /&gt;
 1 row in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
== Server Status Variables ⌘==&lt;br /&gt;
* Status variables  provide information about its operation&lt;br /&gt;
* SHOW [GLOBAL | SESSION] STATUS &lt;br /&gt;
* GLOBAL keyword aggregates the values over all connections&lt;br /&gt;
* SESSION shows the values for the current connection. &lt;br /&gt;
* FLUSH STATUS statement restarts the status variables&lt;br /&gt;
* Cannot be access like system variables via select statement &amp;quot;select @@tmpdir&amp;quot; &lt;br /&gt;
* SHOW GLOBAL STATUS;&lt;br /&gt;
* SHOW SESSION STATUS LIKE &amp;#039;Com_show_status&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
== Local (non system) Variables ⌘==&lt;br /&gt;
* Single &amp;quot;at charater&amp;quot;&lt;br /&gt;
* Visible only in the session&lt;br /&gt;
* Useful with SQL scripts&lt;br /&gt;
 mysql&amp;gt; set @max_salary=20000;&lt;br /&gt;
 Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; select @max_salary;&lt;br /&gt;
 +-------------+&lt;br /&gt;
 | @max_salary |&lt;br /&gt;
 +-------------+&lt;br /&gt;
 |       20000 | &lt;br /&gt;
 +-------------+&lt;br /&gt;
 1 row in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
 MariaDB [test]&amp;gt; select * from emp where sal &amp;gt; @max_salary;&lt;br /&gt;
&lt;br /&gt;
== Using Local Variables to replace subqueries ==&lt;br /&gt;
 MariaDB [test]&amp;gt; select * from emp where sal &amp;gt; (select avg(sal) from emp);&lt;br /&gt;
 +------+----------+-----------+------+------------+---------+------+--------+&lt;br /&gt;
 | ID   | ENAME    | JOB       | MGR  | HIREDATE   | SAL     | COMM | DEPTNO |&lt;br /&gt;
 +------+----------+-----------+------+------------+---------+------+--------+&lt;br /&gt;
 | 7839 | BUSH     | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL |     10 |&lt;br /&gt;
 | 7698 | BLAIR    | MANAGER   | 7839 | 1981-05-01 | 2850.00 | NULL |     30 |&lt;br /&gt;
 | 7782 | MERKEL   | MANAGER   | 7839 | 1981-06-09 | 2450.00 | NULL |     10 |&lt;br /&gt;
 | 7566 | PUTIN    | MANAGER   | 7839 | 1981-04-02 | 2975.00 | NULL |     20 |&lt;br /&gt;
 | 7902 | TOOSK    | ANALYST   | 7566 | 1981-12-03 | 3000.00 | NULL |     20 |&lt;br /&gt;
 | 7788 | CARNEGIE | ANALYST   | 7566 | 1982-12-09 | 3000.00 | NULL |     20 |&lt;br /&gt;
 +------+----------+-----------+------+------------+---------+------+--------+&lt;br /&gt;
 6 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
 MariaDB [test]&amp;gt; select avg(sal) from emp;&lt;br /&gt;
 +-------------+&lt;br /&gt;
 | avg(sal)    |&lt;br /&gt;
 +-------------+&lt;br /&gt;
 | 2073.214286 |&lt;br /&gt;
 +-------------+&lt;br /&gt;
 1 row in set (0.00 sec) &lt;br /&gt;
&lt;br /&gt;
 MariaDB [test]&amp;gt; select avg(sal) from emp into @avg_sal;&lt;br /&gt;
 Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
 MariaDB [test]&amp;gt; select * from emp where sal &amp;gt; @avg_sal;&lt;br /&gt;
 +------+----------+-----------+------+------------+---------+------+--------+&lt;br /&gt;
 | ID   | ENAME    | JOB       | MGR  | HIREDATE   | SAL     | COMM | DEPTNO |&lt;br /&gt;
 +------+----------+-----------+------+------------+---------+------+--------+&lt;br /&gt;
 | 7839 | BUSH     | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL |     10 |&lt;br /&gt;
 | 7698 | BLAIR    | MANAGER   | 7839 | 1981-05-01 | 2850.00 | NULL |     30 |&lt;br /&gt;
 | 7782 | MERKEL   | MANAGER   | 7839 | 1981-06-09 | 2450.00 | NULL |     10 |&lt;br /&gt;
 | 7566 | PUTIN    | MANAGER   | 7839 | 1981-04-02 | 2975.00 | NULL |     20 |&lt;br /&gt;
 | 7902 | TOOSK    | ANALYST   | 7566 | 1981-12-03 | 3000.00 | NULL |     20 |&lt;br /&gt;
 | 7788 | CARNEGIE | ANALYST   | 7566 | 1982-12-09 | 3000.00 | NULL |     20 |&lt;br /&gt;
 +------+----------+-----------+------+------------+---------+------+--------+&lt;br /&gt;
 6 rows in set (0.01 sec)&lt;br /&gt;
&lt;br /&gt;
== Select into variable ⌘==&lt;br /&gt;
 select password from mysql.user where host=&amp;#039;localhost&amp;#039; and user=&amp;#039;root&amp;#039; into @pass;&lt;br /&gt;
&lt;br /&gt;
== Server SQL Modes ==&lt;br /&gt;
* An SQL mode changes the syntax of the SQL and some client behaviours&lt;br /&gt;
* Modes can apply differently for different clients&lt;br /&gt;
* Application written to a different SQL dialects can be used or migrated with less effort&lt;br /&gt;
* The default value is empty (no modes set)&lt;br /&gt;
* Can cause corruption with partitioning&lt;br /&gt;
 SET [GLOBAL|SESSION] sql_mode=&amp;#039;modes&amp;#039; &lt;br /&gt;
 SELECT @@GLOBAL.sql_mode;&lt;br /&gt;
 SELECT @@SESSION.sql_mode;&lt;br /&gt;
* ANSI, DB2, MSSQL, ORACLE, POSTGRESQL, TRADITIONAL&lt;br /&gt;
* More info&lt;br /&gt;
http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html&lt;br /&gt;
&lt;br /&gt;
== The Shutdown Process ⌘==&lt;br /&gt;
* The shutdown process can be initiated several ways. &lt;br /&gt;
** execute a mysqladmin shutdown command. &lt;br /&gt;
** system-specific methods: Unix - SIGTERM signal, Windows - services manager&lt;br /&gt;
*The server might create a thread to handle the shutdown process if necessary.&lt;br /&gt;
*The server stops accepting new connections to prevent new activity from being initiated during shutdown&lt;br /&gt;
*The server terminates current activity&lt;br /&gt;
**open transactions are rolled back&lt;br /&gt;
**nontransactional table, multiple-row UPDATE or INSERT may leave the table partially updated&lt;br /&gt;
*Storage engines are shut down or closed.&lt;br /&gt;
**table cache is flushed&lt;br /&gt;
**all open tables are closed.&lt;br /&gt;
*The server exits.&lt;br /&gt;
== MODULE 3 ==&lt;br /&gt;
== MySQL Security Issues ⌘==&lt;br /&gt;
*Securing MySQL Against Attacks&lt;br /&gt;
*Security-Related mysqld Options&lt;br /&gt;
*Security Issues with LOAD DATA LOCAL&lt;br /&gt;
&lt;br /&gt;
== General Security Guidelines ⌘==&lt;br /&gt;
* Don&amp;#039;t display MySQL credentials in your applications&lt;br /&gt;
* Do not use root account&lt;br /&gt;
* Never grant privileges to all hosts&lt;br /&gt;
* Try mysql -u root&lt;br /&gt;
* SHOW GRANTS statement to check which accounts have access to what&lt;br /&gt;
* Do not choose passwords from dictionaries&lt;br /&gt;
* Put MySQL behind the firewall or in a demilitarized zone (DMZ).&lt;br /&gt;
* SQL InJection&lt;br /&gt;
* Check the size of data before passing it to MySQL&lt;br /&gt;
* Use socket instead of tcp/ip&lt;br /&gt;
&lt;br /&gt;
== Security Guidelines ⌘==&lt;br /&gt;
*The password is not transmitted in clear text over the connection&lt;br /&gt;
*All other information is transferred as text&lt;br /&gt;
**SSL, VPN, SSH&lt;br /&gt;
*Don&amp;#039;t run MySQL server as root (Unix/Linux) or administrator (Windows)&lt;br /&gt;
*Do not grant the PROCESS or SUPER privilege to nonadministrative users. SHOW PROCESSLIST can containt passwords&lt;br /&gt;
*Do not grant the FILE privilege to nonadministrative users&lt;br /&gt;
*If you do not trust your DNS, you should use IP numbers&lt;br /&gt;
*Control number of connections with max_user_connections variable or GRANT statement&lt;br /&gt;
&lt;br /&gt;
== Security Issues with LOAD DATA LOCAL ⌘==&lt;br /&gt;
*The LOAD DATA loads file on the server host or on the client (LOCAL keyword)&lt;br /&gt;
*In a Web environment LOAD DATA LOCAL can read any files that the Web server process has read access &lt;br /&gt;
*You can disable all LOAD DATA LOCAL commands from the server side by starting mysqld with the --local-infile=0 option.&lt;br /&gt;
&lt;br /&gt;
== Memory Configuration ⌘==&lt;br /&gt;
 tmp_table_size=16M&lt;br /&gt;
 sort_buffer_size=208K&lt;br /&gt;
 key_buffer_size=13M&lt;br /&gt;
 read_buffer_size &lt;br /&gt;
 innodb_buffer_pool_size=22M&lt;/div&gt;</summary>
		<author><name>Bernard Szlachta</name></author>
	</entry>
</feed>