Created
March 17, 2023 08:32
-
-
Save ekaitz-zarraga/bb69a45051780b49814ad50ca2be7034 to your computer and use it in GitHub Desktop.
Example session in MySQL from scratch: Creates a user for password auth and a database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alumno ~$ sudo apt install mysql-server mysql-client | |
[sudo] contraseña para alumno: | |
Leyendo lista de paquetes... Hecho | |
Creando árbol de dependencias | |
Leyendo la información de estado... Hecho | |
mysql-client ya está en su versión más reciente (8.0.32-0ubuntu0.20.04.2). | |
mysql-server ya está en su versión más reciente (8.0.32-0ubuntu0.20.04.2). | |
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 16 no actualizados. | |
alumno ~$ sudo mysql | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 8 | |
Server version: 8.0.32-0ubuntu0.20.04.2 (Ubuntu) | |
Copyright (c) 2000, 2023, Oracle and/or its affiliates. | |
Oracle is a registered trademark of Oracle Corporation and/or its | |
affiliates. Other names may be trademarks of their respective | |
owners. | |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> CREATE DATABASE quejas; | |
Query OK, 1 row affected (0,11 sec) | |
mysql> show databases | |
-> ; | |
+--------------------+ | |
| Database | | |
+--------------------+ | |
| information_schema | | |
| mysql | | |
| performance_schema | | |
| phpmyadmin | | |
| quejas | | |
| sys | | |
| tareas | | |
+--------------------+ | |
7 rows in set (0,03 sec) | |
mysql> CREATE USER quejas@localhost IDENTIFIED WITH mysql_native_password BY 'passpass'; | |
Query OK, 0 rows affected (0,15 sec) | |
mysql> GRANT ALL PRIVILEGES ON quejas.* TO quejas@localhost; | |
Query OK, 0 rows affected (0,08 sec) | |
mysql> \q | |
Bye | |
alumno ~$ mysql -u quejas -p | |
Enter password: | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 10 | |
Server version: 8.0.32-0ubuntu0.20.04.2 (Ubuntu) | |
Copyright (c) 2000, 2023, Oracle and/or its affiliates. | |
Oracle is a registered trademark of Oracle Corporation and/or its | |
affiliates. Other names may be trademarks of their respective | |
owners. | |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> show databases; | |
+--------------------+ | |
| Database | | |
+--------------------+ | |
| information_schema | | |
| performance_schema | | |
| quejas | | |
+--------------------+ | |
3 rows in set (0,00 sec) | |
mysql> use quejas; | |
Database changed | |
mysql> CREATE TABLE quejas ( id INTEGER PRIMARY KEY AUTO_INCREMENT, | |
-> body TEXT, | |
-> date DATETIME); | |
Query OK, 0 rows affected (0,39 sec) | |
mysql> show tables; | |
+------------------+ | |
| Tables_in_quejas | | |
+------------------+ | |
| quejas | | |
+------------------+ | |
1 row in set (0,00 sec) | |
mysql> desc quejas | |
-> ; | |
+-------+----------+------+-----+---------+----------------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+----------+------+-----+---------+----------------+ | |
| id | int | NO | PRI | NULL | auto_increment | | |
| body | text | YES | | NULL | | | |
| date | datetime | YES | | NULL | | | |
+-------+----------+------+-----+---------+----------------+ | |
3 rows in set (0,00 sec) | |
mysql> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment