¿Como evito que mysql update elimine los 0 a la izquierda?

Estoy haciendo un UPDATE en mysql y al ejecutarlo ingresa el dato nuevo pero si tiene un 0 a la izquierda lo elimina. Como puedo evitar esto? Ya verifique en el código de php anterior a ejecutar la consulta y la variable todavía tiene el cero a la izquierda, es en el UPDATE que se elimina.

die(var_dump($  pwdNueva));// 0123  $  sql="UPDATE `socios` SET `password`= $  pwdNueva WHERE socios.ci = $  ci";  $  resultado = mysqli_query($  mysqli, $  sql); 

Luego de este código el dato insertado en la base es 123.

In mysql workbench Debugging query I do not see result rows

Hello,
With mysql workbench 6.3 under ubuntu 18 when I want to debug some sql I click “Create a new sql tab for executing queries” toolbar item
and new tab editor is opened. When I click “Execute the selected portion…” toolbar item I see info on the sql executed,
but not result rows, as I expected : https://imgur.com/a/wnRKTUO.
1) Is it some hidden area?

2) I do not want to use all my databases on this connection, How can I hide some databases, without deleting them?

Thanks!

Mysql down after restarting server

I have an Ubuntu 16.04 server with ISPConfig 3.1.

For some reason, the server was working too much on a process with high load, so I restarted the PC. After that, Mysql stopped working and couldn’t be restarted anymore.

I got these messages after trying to restart the service:

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. 

systemctl status mysql.service:

● mysql.service - LSB: Start and stop the mysql database server daemon Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled) Active: failed (Result: exit-code) since jue 2019-08-22 18:58:05 -04; 41s ago Docs: man:systemd-sysv-generator(8) Process: 12020 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS) Process: 12056 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE) 

journalctl -xe:

ago 22 18:58:32 servidor1 mysqld[12230]: /usr/sbin/mysqld[0x955d0c] ago 22 18:58:32 servidor1 mysqld[12230]: /usr/sbin/mysqld[0x93b08e] ago 22 18:58:32 servidor1 mysqld[12230]: /usr/sbin/mysqld[0x93cd7f] ago 22 18:58:32 servidor1 mysqld[12230]: /usr/sbin/mysqld[0xa1dd9d] ago 22 18:58:32 servidor1 mysqld[12230]: /usr/sbin/mysqld[0xa670b6] ago 22 18:58:32 servidor1 mysqld[12230]: /usr/sbin/mysqld[0x9ba375] ago 22 18:58:32 servidor1 mysqld[12230]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f8ba90256ba] ago 22 18:58:32 servidor1 mysqld[12230]: x86_64/clone.S:111(clone)[0x7f8ba84cc41d] ago 22 18:58:32 servidor1 mysqld[12230]: The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains ago 22 18:58:32 servidor1 mysqld[12230]: information that should help you find out what is causing the crash.   ago 22 18:58:52 servidor1 dovecot[904]: auth-worker(12400): Error: sql(dmiranda@comercialkod.cl,152.172.252.195): Password query failed: Not connected to database ago 22 18:58:52 servidor1 dovecot[904]: auth: Error: auth worker: Aborted PASSV request for dmiranda@comercialkod.cl: Lookup timed out ago 22 18:58:52 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:58:53 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:58:54 servidor1 dovecot[904]: imap-login: Aborted login (auth failed, 1 attempts in 62 secs): user=<dmiranda@comercialkod.cl>, method=PLAIN, rip=152.172.252.19 ago 22 18:58:58 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:59:01 servidor1 CRON[12687]: pam_unix(cron:session): session opened for user root by (uid=0) ago 22 18:59:01 servidor1 CRON[12686]: pam_unix(cron:session): session opened for user root by (uid=0) ago 22 18:59:01 servidor1 CRON[12688]: (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$  line" >> /var/log/ispconfig/cron.log ago 22 18:59:01 servidor1 CRON[12689]: (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$  line" >> /var/log/ispconfig/cron.l ago 22 18:59:01 servidor1 CRON[12686]: pam_unix(cron:session): session closed for user root ago 22 18:59:23 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:59:25 servidor1 su[12004]: pam_unix(su:session): session closed for user root ago 22 18:59:25 servidor1 sudo[12003]: pam_unix(sudo:session): session closed for user root ago 22 18:59:27 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:59:28 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:59:33 servidor1 dovecot[904]: auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug ago 22 18:59:34 servidor1 sudo[12790]: surempresa : TTY=pts/20 ; PWD=/home/surempresa ; USER=root ; COMMAND=/bin/su ago 22 18:59:34 servidor1 sudo[12790]: pam_unix(sudo:session): session opened for user root by (uid=0) ago 22 18:59:34 servidor1 su[12809]: Successful su for root by root ago 22 18:59:34 servidor1 su[12809]: + /dev/pts/20 root:root ago 22 18:59:34 servidor1 su[12809]: pam_unix(su:session): session opened for user root by (uid=0) ago 22 18:59:34 servidor1 su[12809]: pam_systemd(su:session): Cannot create session: Already running in a session 

However, I managed to restart the service after I tried the solution from this post:

Can't start MySQL server (database corruption)

So I set:

[mysqld] innodb_force_recovery = 1 

But, it doesn’t work well since some database tables are now read only.

What should I do instead? Thank you.

MySQL Syntax error when trying to create database trigger

When Trying to create the below trigger, I am receiving a syntax error. It looks good to me and I’m having a terrible time trying to figure it out.

  DELIMITER $  $       CREATE TRIGGER trg_pic_hours     AFTER INSERT ON CREW     FOR EACH ROW     BEGIN     IF (NEW.CREW_JOB = 'Pilot') THEN     UPDATE PILOT     SET PIL_PIC_HRS = TEMP_PIL.PIL_PIC_HRS + CHARTER.CHAR_HOURS_FLOWN     WHERE CHARTER.CHAR_TRIP = NEW.CHAR_TRIP     AND PILOT.EMP_NUM = NEW.EMP_NUM;     ENDIF;     END$  $       DELIMITER;  ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; END' at line 10 

Error con el nombre de la tabla en JPA, Hibernate, MySQL

Tengo una clase que se corresponde a una tabla de una base de datos

@Entity @Table(name="TCliente") public class Cliente implements Serializable 

Creo un registro desde código sin problema, luego hago una consulta

EntityManager manager = emf.createEntityManager(); List<Cliente> clientes = (List<Cliente>) manager.createQuery("FROM TCliente").getResultList(); 

y recibo el siguiente error:

INFO: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: TCliente is not mapped [FROM TCliente]     at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138)     at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)     at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)     at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:740)     at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)     at com.jpadomain.test.TestClientes.imprimirTodos(TestClientes.java:68)     at com.jpadomain.test.TestClientes.main(TestClientes.java:33) 

pero si cambio el nombre de la tabla “TCliente” y la llamo “Cliente

@Entity @Table(name="Cliente") public class Cliente implements Serializable 

la consulta funciona perfectamente

EntityManager manager = emf.createEntityManager(); List<Cliente> clientes = (List<Cliente>) manager.createQuery("FROM Cliente").getResultList(); 

Tan sólo con cambiar “TCliente” por “Cliente” ya no me da error siendo ambas tablas idénticas

Como puedo evitar duplicidad de codigo en consulta MYSQL Trabajando con PHP

Tengo el siguiente esquema de tablas, que contienen los datos y detalle de un documento de ventas:

  • DocumentoC — Datos del cliente.
  • DocumentosD — Productos del cliente.
  • DocumentosTMP — Productos temporales al ingresar un documento nuevo.

Consulto el último ID de la tabla DocumentoC para realizar una nueva venta, en donde los productos que se van cargando quedan en la tabla DocumentosTMP (Almacena ID) ya que todavía no esta cerrada la venta.

Al cerrar la venta se obtiene los datos de DocumentosTMP y se pasan a DocumentosD con el ID consultado.

El problema es cuanto trabajan uno o mas usuarios al mismo tiempo. Por ejemplo: UsuarioA y UsuarioB ingresan al mismo tiempo a la pantalla de documentos en donde el sistema les arroja el mismo ID, esto genera conflicto al cerrar la venta por que tienen el mismo ID. ¿Como puedo evitar esto? la estructura no la puedo cambiar por que fue hecho asi…

Gracias. Saludos

How to disable MySQL server from constantly running in the background?

This website explains MySQL server installation in Ubuntu 18.04. Basically you issue the command sudo apt install mysql-server. The same website then explains that:

Once the installation is completed, the MySQL service will start automatically. To check whether the MySQL server is running, type: sudo systemctl status mysql

Does this imply that once I install mysql-server it will always be running in the background unless I explicitly kill the process upon each reboot?

I want to play around with mysql-server occasionally, but don’t want it constantly running in the background.

Can’t change MySQL port in Ubuntu 18.04

I have been trying for hours and can’t find what the issue is.

vim /etc/mysql/my.cnf 

>

!includedir /etc/mysql/conf.d/  !includedir /etc/mysql/mysql.conf.d/  [mysqld]  port=3444  [client]  user=root  password=test123  port=3444 

And the next file:

vim /etc/mysql/mysql.conf.d/mysqld.cnf 

>

[mysqld_safe] socket          = /var/run/mysqld/mysqld.sock nice            = 0  [mysqld] # # * Basic Settings # user            = mysql pid-file        = /var/run/mysqld/mysqld.pid socket          = /var/run/mysqld/mysqld.sock port            = 3444 basedir         = /usr datadir         = /var/lib/mysql tmpdir          = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking # bind-address           = 127.0.0.1 

Then I do a restart:

systemctl restart mysql.service 

But in mysql console, I still see this. Same in systemctl status mysql

mysql> show variables like '%port%'; +--------------------------+-------+ | Variable_name            | Value | +--------------------------+-------+ | innodb_support_xa        | ON    | | large_files_support      | ON    | | port                     | 3306  | | report_host              |       | | report_password          |       | | report_port              | 3306  | | report_user              |       | | require_secure_transport | OFF   | +--------------------------+-------+ 8 rows in set (0.00 sec) 

I was installed apache, node and mysql on ubuntu then I test with postman, it show “Could not get any response”

this is status apache

   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)   Drop-In: /lib/systemd/system/apache2.service.d            └─apache2-systemd.conf    Active: active (running) since Sun 2019-08-18 17:26:55 UTC; 20min ago   Process: 843 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)  Main PID: 930 (apache2)     Tasks: 55 (limit: 1152)    CGroup: /system.slice/apache2.service            ├─930 /usr/sbin/apache2 -k start            ├─935 /usr/sbin/apache2 -k start            └─936 /usr/sbin/apache2 -k start  Aug 18 17:26:54 ubuntu-s-1vcpu-1gb-sgp1-01 systemd[1]: Starting The Apache HTTP Server... Aug 18 17:26:55 ubuntu-s-1vcpu-1gb-sgp1-01 apachectl[843]: AH00558: apache2: Could not reliably determine the server's fully qualif Aug 18 17:26:55 ubuntu-s-1vcpu-1gb-sgp1-01 systemd[1]: Started The Apache HTTP Server. 

and I check my version node is

root@ubuntu-s-1vcpu-1gb-sgp1-01:~# node -v

v10.15.1

and I install mysql and setting like this:

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user; +------------------+-------------------------------------------+-----------------------+-----------+ | user             | authentication_string                     | plugin                | host      | +------------------+-------------------------------------------+-----------------------+-----------+ | root             |                                           | auth_socket           | localhost | | mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | debian-sys-maint | *F1587B7C0C214021D9A8E1EAE12B1EB6A1ECFBF8 | mysql_native_password | localhost | | admin            | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | mysql_native_password | localhost | +------------------+-------------------------------------------+-----------------------+-----------+ 5 rows in set (0.00 sec) 

and I going to change config.js in node to

module.exports = {     secret: "1234",     dbOptions: {         host: "165.22.63.28",         user: "admin",         password: "password",         port: 3306,         database: "dls",         dateStrings: true     } }; 

and I go push this code and git pull on ubuntu then I npm installed and run node index.js

then I test on postman is not work

Could not get any response There was an error connecting to http://165.22.63.28:3013/category. Why this might have happened: The server couldn't send a response: Ensure that the backend is working properly Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General Proxy configured incorrectly Ensure that proxy is configured correctly in Settings > Proxy Request timeout: Change request timeout in Settings > General 

I think it wasn’t work because bind ip and I change bind ip to 165.22.63.28 replace 127.0.0.1 but it wasn’t work too

How can I check what is wrong ?

¿Problema al realizar una condicion en MYSQL?

hola tengo 3 tablas :

  1. tbl_personal_empleado (USUARIOS ACTIVOS)
  2. backuppersonal_empleado (USUARIOS INACTIVOS)
  3. tbl_login

la tabla tbl_personal_empleado contiene 2 tiggers

  1. backup_empleados
  2. usuario_after_insert

el tigger backup_empleado se encarga de de que cuando se elimine un usuario de la tabla este lo inserte en la tabla backuppersonal_empleado basicamente crea una copia, funciona perfectamente.

el tigger usuario_after_insert se encarga que al momento de que se inserte un nuevo usuario este le va a crear un login en la tabla tbl_login con una contraseña aleatorio de 6 digitos para que pueda iniciar sesión el tigger es asi

introducir la descripción de la imagen aquí

ahora la tabla backuppersonal_empleado contiene otro tigger que se encarga de que cuando sea eliminado el usuario este lo inserte en la table tbl_personal_empleado .

la table tbl_login no contiene tiggers ni relaciones su estrutura es asi

introducir la descripción de la imagen aquí

Mi problema es que cuando se habilita un usuario que ya estaba eliminado(DESHABILITADO),la tbl_personal_empleado ejecuta el disparador para crear un nuevo login al usuario que se esta insertando por lo que al final me queda algo asi

introducir la descripción de la imagen aquí

el mismo usuario pero con contraseña nueva, entonces se me ocurrió hacer que el tigger hiciera una validación antes de que si el usuario ya esta insertado en la tbl_login no lo inserte un nuevo login intente esto introducir la descripción de la imagen aquí

pero me saca el siguiente error

MySQL ha dicho: #1064 – Algo está equivocado en su sintax cerca ‘SELECT idpersonal_E FROM tbl_login; SET id =(NEW.idpersonal_E); SET usua’ en la linea 6

y ya no se que mas pueda hacer