Skip to content

Instantly share code, notes, and snippets.

@techyaura
Forked from come-maiz/mysql-tests.md
Created October 27, 2020 18:42
Show Gist options
  • Save techyaura/608f496195d6f552cc04f92fb00f643a to your computer and use it in GitHub Desktop.
Save techyaura/608f496195d6f552cc04f92fb00f643a to your computer and use it in GitHub Desktop.
MySQL snap testing

Smoke tests for the MySQL snap

(based on https://dev.mysql.com/doc/refman/8.0/en/ )

First, install the snap:

$ sudo snap install mysql --channel=8.0/beta

Print the help:

$ mysql.help 
MySQL Snap Image

= MySQL Snap Image =
The MySQL snap image is an experimental release of MySQL for the snap universal Linux package system (http://snapcraft.io/).
This image should be used for testing only, and is not suitable for a production environment.

== Commands ==
[...]

Start the server:

$ mysql.startup
Generating config file in /home/elopio/snap/mysql/common/conf/my.cnf...
Done
Initializing new database in /home/elopio/snap/mysql/common/data...
Done
2017-01-05T05:19:05.178633Z 4 [Note] A temporary password is generated for root@localhost: $temp_password
Starting server...

The server will keep running in that terminal, so open another one.

Open the monitor: (Use the $temp_password printed by mysql.startup)

$ mysql.client -uroot -p
Using config file: /home/elopio/snap/mysql/common/conf/my.cnf
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 8.0.0-dmr
[...]
mysql> 

Print the monitor help:

mysql> help

For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
   https://shop.mysql.com/

List of all MySQL commands:
[...]

Reset your user password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Hola123*';
Query OK, 0 rows affected (0.02 sec)

Run a query:

mysql> SELECT VERSION(), CURRENT_DATE;
+-----------+--------------+
| VERSION() | CURRENT_DATE |
+-----------+--------------+
| 8.0.0-dmr | 2017-01-04   |
+-----------+--------------+
1 row in set (0.00 sec)

Show databases:

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

Create a database:

mysql> CREATE DATABASE menagerie;
Query OK, 1 row affected (0.05 sec)

Switch database:

mysql> USE menagerie
Database changed

Create a table:

mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
Query OK, 0 rows affected (0.23 sec)

Show tables:

mysql> SHOW TABLES;
+---------------------+
| Tables_in_menagerie |
+---------------------+
| pet                 |
+---------------------+
1 row in set (0.00 sec)

Insert a row:

mysql> INSERT INTO pet VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
Query OK, 1 row affected (0.21 sec)

Select a row:

mysql> SELECT * FROM pet WHERE name = 'Puffball';
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
+----------+-------+---------+------+------------+-------+
1 row in set (0.00 sec)

Quit the monitor:

mysql> QUIT
Bye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment