· 8 years ago · Nov 16, 2017, 10:46 AM
1login as: pepe
2Authenticating with public key "rsa-key-20171018"
3Passphrase for key "rsa-key-20171018":
4Last login: Thu Nov 2 18:23:13 2017 from 192.168.20.4
5[pepe@localhost ~]$ mysql -u root -h localhost -p
6Enter password:
7Welcome to the MariaDB monitor. Commands end with ; or \g.
8Your MariaDB connection id is 4
9Server version: 5.5.35-MariaDB MariaDB Server
10
11Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
12
13Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
14
15MariaDB [(none)]> show databases;
16+--------------------+
17| Database |
18+--------------------+
19| information_schema |
20| mysql |
21| performance_schema |
22| test |
23+--------------------+
244 rows in set (0.00 sec)
25
26MariaDB [(none)]> DROP DATABASE IF EXIST TPV;
27ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'EXI ST TPV' at line 1
28MariaDB [(none)]> CREATE DATABASE TPV;
29Query OK, 1 row affected (0.00 sec)
30
31MariaDB [(none)]> show databases;
32+--------------------+
33| Database |
34+--------------------+
35| information_schema |
36| TPV |
37| mysql |
38| performance_schema |
39| test |
40+--------------------+
415 rows in set (0.00 sec)
42
43MariaDB [(none)]> use TPV;
44Database changed
45MariaDB [TPV]> CREATE TABLE Empleados (
46 -> Ctrl-C -- exit!
47Aborted
48[pepe@localhost ~]$ mysql -u root -h localhost -p
49Enter password:
50Welcome to the MariaDB monitor. Commands end with ; or \g.
51Your MariaDB connection id is 5
52Server version: 5.5.35-MariaDB MariaDB Server
53
54Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
55
56Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
57
58MariaDB [(none)]> show databases;
59+--------------------+
60| Database |
61+--------------------+
62| information_schema |
63| TPV |
64| mysql |
65| performance_schema |
66| test |
67+--------------------+
685 rows in set (0.00 sec)
69
70MariaDB [(none)]> USE tpv;
71ERROR 1049 (42000): Unknown database 'tpv'
72MariaDB [(none)]> USE TPV;
73Database changed
74MariaDB [TPV]> show tables;
75Empty set (0.00 sec)
76
77MariaDB [TPV]> show tables;
78Empty set (0.00 sec)
79
80MariaDB [TPV]> CREATE TABLE Empleados ( id_empleado int primary key auto_increme nt, nombre varchar(50), apellidos varchar(50)) Engine=InnoDB;
81Query OK, 0 rows affected (0.03 sec)
82
83MariaDB [TPV]> show databases;
84+--------------------+
85| Database |
86+--------------------+
87| information_schema |
88| TPV |
89| mysql |
90| performance_schema |
91| test |
92+--------------------+
935 rows in set (0.00 sec)
94
95MariaDB [TPV]> show tables;
96+---------------+
97| Tables_in_TPV |
98+---------------+
99| Empleados |
100+---------------+
1011 row in set (0.00 sec)
102
103MariaDB [TPV]> CREATE TABLE Productos ( id_producto int primary key auto_increme nt, nombre varchar(50), pvp float(4,2)) Engine=InnoDB;
104Query OK, 0 rows affected (0.02 sec)
105
106MariaDB [TPV]> CREATE TABLE Ticket ( id_ticket int primary key auto_increment, f echa_hora timestamp not null, pvp float(4,2) not null, empleadosid int not null, CONSTRAINT ticket_empleadosfk FOREIGN KEY (empleadosid) REFERENCES Empleados (id _empleado)) Engine=InnoDB;
107Query OK, 0 rows affected (0.02 sec)
108
109MariaDB [TPV]> show tables;
110+---------------+
111| Tables_in_TPV |
112+---------------+
113| Empleados |
114| Productos |
115| Ticket |
116+---------------+
1173 rows in set (0.00 sec)
118
119MariaDB [TPV]> CREATE TABLE Ticket_Productos (id_ticket_producto int primary key auto_increment, cantidad int, precio_unidad float(4,2), ticketid int not null, CONSTRAINT ticketproductos_ticketfk FOREIGN KEY (ticketid) REFERENCES Ticket (id _ticket))Engine=InnoDB;
120Query OK, 0 rows affected (0.01 sec)
121
122MariaDB [TPV]> show tables;
123+------------------+
124| Tables_in_TPV |
125+------------------+
126| Empleados |
127| Productos |
128| Ticket |
129| Ticket_Productos |
130+------------------+
1314 rows in set (0.00 sec)
132
133MariaDB [TPV]> DROP IF EXISTS Ticket_Productos;
134ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF EXISTS Ticket_Productos' at line 1
135MariaDB [TPV]> DROP IF EXISTS Ticket_Productos
136 -> Ctrl-C -- exit!
137Aborted
138[pepe@localhost ~]$ mysql -u root -h localhost -p
139Enter password:
140Welcome to the MariaDB monitor. Commands end with ; or \g.
141Your MariaDB connection id is 6
142Server version: 5.5.35-MariaDB MariaDB Server
143
144Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
145
146Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
147
148MariaDB [(none)]> DROP IF EXISTS Ticket_Productos,
149 -> Ctrl-C -- exit!
150Aborted
151[pepe@localhost ~]$ mysql -u root -h localhost -p
152Enter password:
153Welcome to the MariaDB monitor. Commands end with ; or \g.
154Your MariaDB connection id is 7
155Server version: 5.5.35-MariaDB MariaDB Server
156
157Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
158
159Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
160
161MariaDB [(none)]> show tables;
162ERROR 1046 (3D000): No database selected
163MariaDB [(none)]> show databases;
164+--------------------+
165| Database |
166+--------------------+
167| information_schema |
168| TPV |
169| mysql |
170| performance_schema |
171| test |
172+--------------------+
1735 rows in set (0.00 sec)
174
175MariaDB [(none)]> use TPV;
176Reading table information for completion of table and column names
177You can turn off this feature to get a quicker startup with -A
178
179Database changed
180MariaDB [TPV]> show databases;
181+--------------------+
182| Database |
183+--------------------+
184| information_schema |
185| TPV |
186| mysql |
187| performance_schema |
188| test |
189+--------------------+
1905 rows in set (0.00 sec)
191
192MariaDB [TPV]> show tables;
193+------------------+
194| Tables_in_TPV |
195+------------------+
196| Empleados |
197| Productos |
198| Ticket |
199| Ticket_Productos |
200+------------------+
2014 rows in set (0.00 sec)
202
203MariaDB [TPV]> Ctrl-C -- exit!
204Aborted
205[pepe@localhost ~]$ mysqldump TPV -p > script_TPV.sql
206Enter password:
207mysqldump: Got error: 1044: "Access denied for user ''@'localhost' to database ' TPV'" when selecting the database
208[pepe@localhost ~]$ mysqldump TPV -p > script_TPV.sql
209Enter password:
210mysqldump: Got error: 1045: "Access denied for user 'pepe'@'localhost' (using pa ssword: YES)" when trying to connect
211[pepe@localhost ~]$ su -
212Contraseña:
213Último inicio de sesión:jue nov 2 18:23:42 CET 2017en pts/0
214[root@localhost ~]# mysqldump TPV -p > script_TPV.sql
215Enter password:
216[root@localhost ~]# vi script_TPV.sql
217-- MySQL dump 10.14 Distrib 5.5.35-MariaDB, for Linux (x86_64)
218--
219-- Host: localhost Database: TPV
220-- ------------------------------------------------------
221-- Server version 5.5.35-MariaDB
222
223/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
224/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
225/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
226/*!40101 SET NAMES utf8 */;
227/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
228/*!40103 SET TIME_ZONE='+00:00' */;
229/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
230/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
231/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
232/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
233
234--
235-- Table structure for table `Empleados`
236--
237
238DROP TABLE IF EXISTS `Empleados`;
239/*!40101 SET @saved_cs_client = @@character_set_client */;
240/*!40101 SET character_set_client = utf8 */;
241CREATE TABLE `Empleados` (
242 `id_empleado` int(11) NOT NULL AUTO_INCREMENT,
243 `nombre` varchar(50) DEFAULT NULL,
244 `apellidos` varchar(50) DEFAULT NULL,
245 PRIMARY KEY (`id_empleado`)
246) ENGINE=InnoDB DEFAULT CHARSET=latin1;
247/*!40101 SET character_set_client = @saved_cs_client */;
248
249--
250-- Dumping data for table `Empleados`
251--
252
253LOCK TABLES `Empleados` WRITE;
254/*!40000 ALTER TABLE `Empleados` DISABLE KEYS */;
255/*!40000 ALTER TABLE `Empleados` ENABLE KEYS */;
256UNLOCK TABLES;
257
258--
259-- Table structure for table `Productos`
260--
261
262DROP TABLE IF EXISTS `Productos`;
263/*!40101 SET @saved_cs_client = @@character_set_client */;
264/*!40101 SET character_set_client = utf8 */;
265CREATE TABLE `Productos` (
266 `id_producto` int(11) NOT NULL AUTO_INCREMENT,
267 `nombre` varchar(50) DEFAULT NULL,
268 `pvp` float(4,2) DEFAULT NULL,
269 PRIMARY KEY (`id_producto`)
270) ENGINE=InnoDB DEFAULT CHARSET=latin1;
271/*!40101 SET character_set_client = @saved_cs_client */;
272
273--
274-- Dumping data for table `Productos`
275--