author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 30 Dec 2015 11:40:18 +0200 | |
changeset 1853 | c6be6cc87df4 |
parent 1852 | f572f646694b |
child 1854 | 9b224b68c1e1 |
permissions | -rw-r--r-- |
1809 | 1 |
.. -*- coding: utf-8; -*- |
2 |
.. include:: HEADER.rst |
|
3 |
||
4 |
================ |
|
5 |
MySQL/MariaBD. |
|
6 |
================ |
|
7 |
.. contents:: |
|
8 |
||
9 |
SQL clients. |
|
10 |
============ |
|
11 |
||
1810 | 12 |
https://mariadb.com/kb/en/mariadb/clients-and-utilities/ |
13 |
Clients and Utilities. |
|
14 |
https://mariadb.com/kb/en/mariadb/graphical-and-enhanced-clients/ |
|
15 |
Graphical and Enhanced Clients. |
|
16 |
||
1809 | 17 |
mysql. |
18 |
------ |
|
19 |
||
20 |
Official client. Install ``mariadb-client`` package - ``mysql`` utility |
|
21 |
will be installed with dependent package. |
|
22 |
||
23 |
Usage:: |
|
24 |
||
25 |
$ mysql -u $USER -p |
|
26 |
Enter password: <== Type password. |
|
27 |
||
1851
e6ffc5f7200e
To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1850
diff
changeset
|
28 |
To save content of session interaction in ``mysql`` use:: |
e6ffc5f7200e
To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1850
diff
changeset
|
29 |
|
e6ffc5f7200e
To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1850
diff
changeset
|
30 |
mysql> tee out.txt |
e6ffc5f7200e
To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1850
diff
changeset
|
31 |
|
1809 | 32 |
mycli. |
33 |
------ |
|
34 |
||
35 |
Python command line client with completion. Usage:: |
|
36 |
||
37 |
$ mycli -u $USER |
|
38 |
Password: <== Type password. |
|
39 |
||
1811
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
40 |
List databases, tables, columns. |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
41 |
================================ |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
42 |
:: |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
43 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
44 |
$ mysql -u $USER -p |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
45 |
Enter password: <== Type password. |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
46 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
47 |
SHOW DATABASES; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
48 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
49 |
USE mysql; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
50 |
MariaDB [mysql]> SHOW TABLES; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
51 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
52 |
MariaDB [mysql]> SHOW COLUMNS FROM user; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
53 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
54 |
MariaDB [mysql]> DESCRIBE user; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
55 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
56 |
MariaDB [mysql]> SHOW STATUS; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
57 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
58 |
MariaDB [mysql]> SHOW CREATE DATABASE mysql; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
59 |
MariaDB [mysql]> SHOW CREATE TABLE user; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
60 |
|
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
61 |
MariaDB [mysql]> SHOW GRANTS; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
62 |
|
1849
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
63 |
System information. |
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
64 |
=================== |
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
65 |
|
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
66 |
Server version, platform, etc:: |
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
67 |
|
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
68 |
[mysql]> SHOW VARIABLES LIKE "%version%"; |
a3b639d803e7
System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1836
diff
changeset
|
69 |
|
1850
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
70 |
Debugging queries error. |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
71 |
======================== |
1836 | 72 |
|
73 |
After error or warning run:: |
|
74 |
||
1811
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
75 |
MariaDB [mysql]> SHOW WARNINGS; |
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
76 |
MariaDB [mysql]> SHOW ERRORS; |
1836 | 77 |
MariaDB [mysql]> show engine innodb status; |
1811
072cc8a704ce
List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1810
diff
changeset
|
78 |
|
1850
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
79 |
Monitor server execution. |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
80 |
========================= |
1852
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
81 |
|
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
82 |
List all current executions:: |
1850
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
83 |
|
1852
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
84 |
MariaDB [mysql]> show processlist; |
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
85 |
|
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
86 |
Dump execution plan for selected process:: |
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
87 |
|
f572f646694b
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1851
diff
changeset
|
88 |
MariaDB [mysql]> show explain for 1; |
1850
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
89 |
|
1853
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
90 |
.. NOTE:: |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
91 |
You shoud check for code ``1003``:: |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
92 |
|
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
93 |
MariaDB [mysql]> show warnings; |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
94 |
|
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
95 |
to ensure for which query plan shown becase query may finished and new |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
96 |
started. |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
97 |
|
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
98 |
See: |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
99 |
|
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
100 |
* `SHOW EXPLAIN in MariaDB 10.0 vs EXPLAIN FOR CONNECTION in MySQL 5.7 |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
101 |
<http://s.petrunia.net/blog/?p=89>`_ |
c6be6cc87df4
Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1852
diff
changeset
|
102 |
|
1850
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
103 |
Profiling queries. |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
104 |
================== |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
105 |
|
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
106 |
Enable profiling, execute query and review profiling data:: |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
107 |
|
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
108 |
[mysql]> set profiling=1; |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
109 |
[mysql]> select 1; |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
110 |
[mysql]> show profile; |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
111 |
|
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
112 |
Each profiled query results stored separately. To get list of results:: |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
113 |
|
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
114 |
[mysql]> show profiles; |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
115 |
|
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
116 |
To retrieve selected profiling data:: |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
117 |
|
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
118 |
[mysql]> show profile for query 1; |
84707c692266
Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1849
diff
changeset
|
119 |