Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I've seen it. It's rubbish." -- Marvin the Paranoid Android


devel / comp.databases.mysql / Re: From bash script (Debian Bookworm) login and query to MariaDB

SubjectAuthor
* From bash script (Debian Bookworm) login and query to MariaDB^Bart
+* Re: From bash script (Debian Bookworm) login and query to MariaDBThe Natural Philosopher
|`* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
| `* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
|  +* Re: From bash script (Debian Bookworm) login and query to MariaDBJ.O. Aho
|  |`* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
|  | `- Re: From bash script (Debian Bookworm) login and query to MariaDBJ.O. Aho
|  `* Re: From bash script (Debian Bookworm) login and query to MariaDBJerry Stuckle
|   `* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
|    `* Re: From bash script (Debian Bookworm) login and query to MariaDBThe Natural Philosopher
|     `* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
|      `* Re: From bash script (Debian Bookworm) login and query to MariaDBJ.O. Aho
|       +- Re: From bash script (Debian Bookworm) login and query to MariaDBJerry Stuckle
|       `* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
|        `- Re: From bash script (Debian Bookworm) login and query to MariaDBJ.O. Aho
+* Re: From bash script (Debian Bookworm) login and query to MariaDBMarco Moock
|`- Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
+* Re: From bash script (Debian Bookworm) login and query to MariaDBJerry Stuckle
|`* Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart
| `- Re: From bash script (Debian Bookworm) login and query to MariaDBJ.O. Aho
`* Re: From bash script (Debian Bookworm) login and query to MariaDBJ.O. Aho
 `- Re: From bash script (Debian Bookworm) login and query to MariaDB^Bart

1
From bash script (Debian Bookworm) login and query to MariaDB

<uhr78k$13p7r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=101&group=comp.databases.mysql#101

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: From bash script (Debian Bookworm) login and query to MariaDB
Date: Tue, 31 Oct 2023 16:42:12 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <uhr78k$13p7r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 31 Oct 2023 15:42:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="52da66acb80472322091af228804f0cf";
logging-data="1172731"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eGHirZOWsR6VAdujx8nG46mYOA8ND/fE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:GCrJnkRGn6tgVmQH7tkQD7afPjo=
Content-Language: en-US
 by: ^Bart - Tue, 31 Oct 2023 15:42 UTC

Hi guys,

I need to write in bash a script which do these things:

1) Login to MariaDB;
2) Truncate a table to make it empty;
3) Import data from a file to this table.

I found this guide
https://notearena.com/lesson/how-to-access-databasemysql-mariadb-in-linux-shell-scripting/
and I'd like to know if it's the right way! :)

Now I do everything manually...

Regards.
^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhrmcl$16ilv$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=102&group=comp.databases.mysql#102

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tnp...@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Tue, 31 Oct 2023 20:00:21 +0000
Organization: A little, after lunch
Lines: 28
Message-ID: <uhrmcl$16ilv$2@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 31 Oct 2023 20:00:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="062571949964abaa4330d72e8ea3c272";
logging-data="1264319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196dmKH/pSMLLe/DFlC50v8Q21N3wu64xQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NrnjfYf6A04RWQuS1i2/kba3Zmg=
In-Reply-To: <uhr78k$13p7r$1@dont-email.me>
Content-Language: en-GB
 by: The Natural Philosop - Tue, 31 Oct 2023 20:00 UTC

On 31/10/2023 15:42, ^Bart wrote:
> Hi guys,
>
> I need to write in bash a script which do these things:
>
> 1) Login to MariaDB;
> 2) Truncate a table to make it empty;
> 3) Import data from a file to this table.
>
> I found this guide
> https://notearena.com/lesson/how-to-access-databasemysql-mariadb-in-linux-shell-scripting/ and I'd like to know if it's the right way! :)
>
> Now I do everything manually...
>
> Regards.
> ^Bart

I'd almost certainly write that in C or PHP. The APIS are very simple
for something like that.

--
If I had all the money I've spent on drink...
...I'd spend it on drink.

Sir Henry (at Rawlinson's End)

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhrmem$16h4m$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=103&group=comp.databases.mysql#103

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mm+usene...@dorfdsl.de (Marco Moock)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Tue, 31 Oct 2023 21:01:26 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <uhrmem$16h4m$2@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 31 Oct 2023 20:01:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9a33b3e22306cfe0df5310bdec17cb43";
logging-data="1262742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P9Z/AUUHv8upeA6gvwgH6"
Cancel-Lock: sha1:MM5SdcsPx/df5carohYXthUNH/8=
 by: Marco Moock - Tue, 31 Oct 2023 20:01 UTC

Am 31.10.2023 um 16:42:12 Uhr schrieb ^Bart:

> I found this guide
> https://notearena.com/lesson/how-to-access-databasemysql-mariadb-in-linux-shell-scripting/
> and I'd like to know if it's the right way! :)

At first glace, that looks good, give it a try on a test database.

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhs1am$189pa$1@jstuckle.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=104&group=comp.databases.mysql#104

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: stuckle....@gmail.com (Jerry Stuckle)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Tue, 31 Oct 2023 19:06:48 -0400
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <uhs1am$189pa$1@jstuckle.eternal-september.org>
References: <uhr78k$13p7r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 31 Oct 2023 23:07:02 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="aeec689409778786144fe5e69a391458";
logging-data="1320746"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IqMG6s/9p0+Mx1OZTl40tyPUhsXedSyg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:tNu9rf0ImwwH/fQospHRMw9+NtA=
Content-Language: en-US
In-Reply-To: <uhr78k$13p7r$1@dont-email.me>
 by: Jerry Stuckle - Tue, 31 Oct 2023 23:06 UTC

On 10/31/2023 11:42 AM, ^Bart wrote:
> Hi guys,
>
> I need to write in bash a script which do these things:
>
> 1) Login to MariaDB;
> 2) Truncate a table to make it empty;
> 3) Import data from a file to this table.
>
> I found this guide
> https://notearena.com/lesson/how-to-access-databasemysql-mariadb-in-linux-shell-scripting/ and I'd like to know if it's the right way! :)
>
> Now I do everything manually...
>
> Regards.
> ^Bart

You don't need anything but SQL and the CLI.

Just create a text file with the SQL commands necessary to use the
database, truncate the table and import from the file. Call it
reload.sql, for instance.

Then use the CLI source command to run that file, i.e.

mysql -u user -ppassword
source reload.sql

Or you could do it with

mysql -u user -ppassword < reload.sql

It's not a good idea to have the password in a file.

--
==================
Remove the "x"'s from my email address
Jerry Stuckle
stucklex.jerryx@gmail.com
==================

Re: From bash script (Debian Bookworm) login and query to MariaDB

<kqebjoFam3fU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=105&group=comp.databases.mysql#105

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: use...@example.net (J.O. Aho)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Wed, 1 Nov 2023 08:04:24 +0100
Lines: 50
Message-ID: <kqebjoFam3fU1@mid.individual.net>
References: <uhr78k$13p7r$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net +wIZqRVC/5ruKmZol8QxggzcjhYNBMIPO5i3U2NUXT4RxGGsT3
Cancel-Lock: sha1:tzaM4zqHUG3/LSPv62lZJNAX0hw= sha256:vuM6tyhM4Vep2sBBlYGBme5YhdZEjENlyfvlZ/ZESKA=
User-Agent: Mozilla Thunderbird
Content-Language: en-US-large
In-Reply-To: <uhr78k$13p7r$1@dont-email.me>
 by: J.O. Aho - Wed, 1 Nov 2023 07:04 UTC

On 31/10/2023 16.42, ^Bart wrote:
> Hi guys,
>
> I need to write in bash a script which do these things:
>
> 1) Login to MariaDB;
> 2) Truncate a table to make it empty;
> 3) Import data from a file to this table.
>
> I found this guide
> https://notearena.com/lesson/how-to-access-databasemysql-mariadb-in-linux-shell-scripting/ and I'd like to know if it's the right way! :)
>
> Now I do everything manually...

The main issue with that script is the base64 encoded password, from
security standard point of view that is still as if the password was
stored in plain text.

As Jerry pointed out, you can just do everything with a simple file with
the sql commands and run it with the command line, but with the
exception that I wouldn't use the password in the command line but let
the mysql command for prompting me to enter the password, as otherwise
you store the plain text password in bash history.

mysql -hhost -uuser -p < reload.sql

sure if you need to automate this like running cron job, then you will
need to provide a password, then see to that the file is just readable
by the user it's executed as and that user ain't someone that people
just can login in with, don't forget that by default root will be able
to read the file.

You may also consider to create a store procedure that does everything
you need,

https://mariadb.com/kb/en/create-procedure/
https://mariadb.com/kb/en/stored-routine-privileges/
https://mariadb.com/kb/en/call/

then you don't have to have a script on each machine you may need to
execute the truncation and stuff from and of course you shouldn't let
every database user to use it, just those that are authorized to do the
job.

mysql -hhost -uuser -p database -e "CALL sp_you_created;"

--
//Aho

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhvn6g$23nq2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=106&group=comp.databases.mysql#106

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 09:39:37 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <uhvn6g$23nq2$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 2 Nov 2023 08:38:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7efdf23e6d389873aebeb78f9a68d2df";
logging-data="2219842"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DtctDRmho91YS9ZgVC17CXAX3MtFtG9Q="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:yTmuHcRINZrY5R3XnZ1opyr3sE0=
Content-Language: en-US
In-Reply-To: <uhrmcl$16ilv$2@dont-email.me>
 by: ^Bart - Thu, 2 Nov 2023 08:39 UTC

> I'd almost certainly write that in C or PHP.  The APIS are very simple
> for something like that.

Thanks for your reply, I used PHP years and years ago and I don't
remember it very well but really thanks to share this solution! :)

^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhvn8m$23nq2$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=107&group=comp.databases.mysql#107

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 09:40:47 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uhvn8m$23nq2$2@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmem$16h4m$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Nov 2023 08:39:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7efdf23e6d389873aebeb78f9a68d2df";
logging-data="2219842"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19x1oP26VpPd19uhd3TP9pAI7pSqrws5NA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:CpIe+iUisgDo/oOGXUPIfCVn/qo=
In-Reply-To: <uhrmem$16h4m$2@dont-email.me>
Content-Language: en-US
 by: ^Bart - Thu, 2 Nov 2023 08:40 UTC

>> I found this guide
>> https://notearena.com/lesson/how-to-access-databasemysql-mariadb-in-linux-shell-scripting/
>> and I'd like to know if it's the right way! :)
>
> At first glace, that looks good, give it a try on a test database.

Thanks for your reply, sure I'll do it in a test db! :)

^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhvnrk$23sgb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=108&group=comp.databases.mysql#108

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 09:50:52 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uhvnrk$23sgb$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me>
<uhs1am$189pa$1@jstuckle.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 2 Nov 2023 08:49:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7efdf23e6d389873aebeb78f9a68d2df";
logging-data="2224651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+36IOHgp6uwDCg7pJvp5Y+ocXX5VgSTnA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:O5l6lrzba6sruUrrdJv3A2mEhqw=
Content-Language: en-US
In-Reply-To: <uhs1am$189pa$1@jstuckle.eternal-september.org>
 by: ^Bart - Thu, 2 Nov 2023 08:50 UTC

> You don't need anything but SQL and the CLI.

Ok!

> Just create a text file with the SQL commands necessary to use the
> database, truncate the table and import from the file.  Call it
> reload.sql, for instance.

Ok.

> Then use the CLI source command to run that file, i.e.
>
> mysql -u user -ppassword
> source reload.sql

So... I should have a file where I'll store the login data and I could
name it like "login.sql" and inside of it I should insert the "reload.sql".

At the end I should add the link to "login.sql" in crontab because I
should run it every 5 minutes.

> Or you could do it with
>
> mysql -u user -ppassword < reload.sql

Ok.

> It's not a good idea to have the password in a file.

I know but this is a test machine inside of my lan, it's not in DMZ and
just me or one colleague can login to it but you got the point about
security risks and in your opinion could I solve this "issue" with the
idea showed in the link which I posted in my first message or do you
have another idea?

Regards.
^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhvou5$242ov$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=109&group=comp.databases.mysql#109

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 10:09:18 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <uhvou5$242ov$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <kqebjoFam3fU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Nov 2023 09:08:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7efdf23e6d389873aebeb78f9a68d2df";
logging-data="2231071"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pb3GvIZl0ZFljE7A9geMVYEePQbZCASg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Fl9WU061pH0ZNaLnKHycq2gN8ag=
In-Reply-To: <kqebjoFam3fU1@mid.individual.net>
Content-Language: en-US
 by: ^Bart - Thu, 2 Nov 2023 09:09 UTC

> The main issue with that script is the base64 encoded password, from
> security standard point of view that is still as if the password was
> stored in plain text.

I didn't think about this issue... :\

> sure if you need to automate this like running cron job, then you will
> need to provide a password, then see to that the file is just readable
> by the user it's executed as and that user ain't someone that people
> just can login in with, don't forget that by default root will be able
> to read the file.

Yes, this is what I need a cron job to automate the process.

> You may also consider to create a store procedure that does everything
> you need,
>
> https://mariadb.com/kb/en/create-procedure/
> https://mariadb.com/kb/en/stored-routine-privileges/
> https://mariadb.com/kb/en/call/

[CUT]

I didn't know it and this is a good idea to start to study something new
to improve "my skills" (and obviously to improve the security field!);
I'm working on a test machine in our lan (not in DMZ) so just me and one
colleague can login there, now I need to solve this "problem" because
another colleague is waiting me with Knime to do queries from MariaDB
and I'll use the dirty way! :)

Really thanks also to you for this great reply! :)

Have a nice day!
^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<uhvun1$256tt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=110&group=comp.databases.mysql#110

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 11:46:57 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <uhvun1$256tt$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Nov 2023 10:46:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7efdf23e6d389873aebeb78f9a68d2df";
logging-data="2268093"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EGmS/Bp0Y1JDMRtMsA4RON+o3SglNyC4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cHtin2/GiS7G4rUrSEN/OT1a9mQ=
In-Reply-To: <uhvn6g$23nq2$1@dont-email.me>
Content-Language: en-US
 by: ^Bart - Thu, 2 Nov 2023 10:46 UTC

> Thanks for your reply, I used PHP years and years ago and I don't
> remember it very well but really thanks to share this solution! :)

I did in my crontab this:

*/5 * * * * /usr/bin/mysql -u my_username -h localhost -p my_password <
/home/itoffice/query.sql

It doesn't work... :/

If I run query.sql after I did a manual login in MariaDB it works.

I think I must use php like what this site said:
https://stackoverflow.com/questions/9948220/how-can-i-set-a-crontab-to-execute-a-mysql-query-and-log-the-output

I think also I should save php file not in my home folder like
/home/itoffice but in /var/www/html right?

^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<kqhdvhFtbq5U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=111&group=comp.databases.mysql#111

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: use...@example.net (J.O. Aho)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 12:03:13 +0100
Lines: 37
Message-ID: <kqhdvhFtbq5U1@mid.individual.net>
References: <uhr78k$13p7r$1@dont-email.me>
<uhs1am$189pa$1@jstuckle.eternal-september.org>
<uhvnrk$23sgb$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net KpT5zuSHAfgKzt9pmZpmPgFMdnOaidqw5eauE2F8Q2t2C5FIEi
Cancel-Lock: sha1:E+OrA5I45tGS6ZzFHdheBmjVrtI= sha256:TM/WgDV1d8VKQDkBdH5XtZytig+R1+QaA0j7DPwetyI=
User-Agent: Mozilla Thunderbird
Content-Language: en-US-large
In-Reply-To: <uhvnrk$23sgb$1@dont-email.me>
 by: J.O. Aho - Thu, 2 Nov 2023 11:03 UTC

On 02/11/2023 09.50, ^Bart wrote:
>> You don't need anything but SQL and the CLI.
>
> Ok!
>
>> Just create a text file with the SQL commands necessary to use the
>> database, truncate the table and import from the file.  Call it
>> reload.sql, for instance.
>
> Ok.
>
>> Then use the CLI source command to run that file, i.e.
>>
>> mysql -u user -ppassword < reload.sql
>
> So... I should have a file where I'll store the login data and I could
> name it like "login.sql" and inside of it I should insert the "reload.sql".

No, the sql file will only include the raw SQL queries in the same way
as you would have when you type in the mysql after you logged in.

Credentials can be stored in a configuration file, here is an example
for MySQL, but works exactly the same way for MariaDB:

https://www.serverlab.ca/tutorials/linux/database-servers/how-to-create-a-credential-file-for-mysql/

In you case I would maybe create a new user, create a profile (I hope
this part is in MariaDB). See to that the default login shell is
/sbin/nologin and then you see to that the cronjob is run as this user
(in this example: dbcronuser).

* 5 * * * dbcronuser (mysql --login-path=backups <
/home/dbcronuser/reload.sql)

--
//Aho

Re: From bash script (Debian Bookworm) login and query to MariaDB

<kqhf2pFtbq4U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=112&group=comp.databases.mysql#112

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!news.nntp4.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: use...@example.net (J.O. Aho)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 12:22:01 +0100
Lines: 43
Message-ID: <kqhf2pFtbq4U1@mid.individual.net>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net hwDg/5AN0KN6xJtqnGudjg8GJSQ9YQU3OFzrWLA3lK6R4jukC5
Cancel-Lock: sha1:rjkuyHzlAyfWYK6gVYU0YuJg2qQ= sha256:LrOu09UmzVR9VN4vRYYlD1bcNGQV29NFaWx6Yi0/V7Q=
User-Agent: Mozilla Thunderbird
Content-Language: en-US-large
In-Reply-To: <uhvun1$256tt$1@dont-email.me>
 by: J.O. Aho - Thu, 2 Nov 2023 11:22 UTC

On 02/11/2023 11.46, ^Bart wrote:
>> Thanks for your reply, I used PHP years and years ago and I don't
>> remember it very well but really thanks to share this solution! :)
>
> I did in my crontab this:
>
> */5 * * * * /usr/bin/mysql -u my_username -h localhost -p my_password <
> /home/itoffice/query.sql

this in /etc/crontab or did you use it as your personal crontab with
"crontab -e"?

if the later, then your user need to have the right to read the file and
of course have the right to access the content in the itoffice directory.

if /etc/crontab then add who is executing the command and it can be good
to put parentheses around command too

*/5 * * * * (root) (/usr/bin/mysql -umy_username -pmy_password
databasename <
/home/itoffice/query.sql)

> I think I must use php like what this site said:
> https://stackoverflow.com/questions/9948220/how-can-i-set-a-crontab-to-execute-a-mysql-query-and-log-the-output

No you don't, it's just what he did.

> I think also I should save php file not in my home folder like
> /home/itoffice but in /var/www/html right?

That is much about how you use the php script, if you use it like a bash
script then no you don't put it there. If it's part of your web site,
then yes.

Php can be used for websites, scripting and even create gui
applications, it may not be the best option in all situations.

--
//Aho

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui0ae6$27ame$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=113&group=comp.databases.mysql#113

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 15:07:02 +0100
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <ui0ae6$27ame$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<kqhf2pFtbq4U1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 2 Nov 2023 14:07:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7efdf23e6d389873aebeb78f9a68d2df";
logging-data="2337486"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+s0DGotaBCNALrNZLfTZBtBlW9xZh+UaM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UM9q+eNmtArotun1I3uajuCaQ2k=
In-Reply-To: <kqhf2pFtbq4U1@mid.individual.net>
Content-Language: en-US
 by: ^Bart - Thu, 2 Nov 2023 14:07 UTC

> */5 * * * * (root) (/usr/bin/mysql -umy_username -pmy_password
> databasename <
>  /home/itoffice/query.sql)

*/5 * * * * (itoffice) (/usr/bin/mysql -u username -p password db_name <
/home/it_office/query.sql)

It doesn't work :\ but it doesn't work also if I insert it in a php
script; here below is the working *.sql file used from MariaDB CLI:

USE db_name;
TRUNCATE items_temp;

LOAD DATA LOCAL INFILE '/home/itoffice/data_bridge/items.txt'
INTO TABLE items_temp
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(id_tc_anartic, cod_art, desc_art, ump, umi, coef_ump_umi, gest_maga,
cod_iva, cod_cat_cont, desc_cat_cont, cod_class_pat, art_stato,
disabilitato, ean, peso_netto, peso_lordo, um_peso, lunghezza,
larghezza, altezza, diametro , cod_cat01 , desc_cat01 ,
cod_cat02, desc_cat02, cod_cat03, desc_cat03, cod_cat04, desc_cat04,
cod_cat05, desc_cat05, cod_cat06, desc_cat06, cod_cat07,
desc_cat07, cod_cat08, desc_cat08, cod_cat09, desc_cat09, cod_cat10,
desc_cat10, cod_cat11, desc_cat11, cod_cat12, desc_cat12,
cod_cat13, desc_cat13, cod_cat14, desc_cat14, cod_cat15, desc_cat15,
cod_cat16, desc_cat16, cod_cat17, desc_cat17, cod_cat18,
desc_cat18, cod_cat19, desc_cat19, cod_cat20, desc_cat20, dt_creazione,
dt_last_upd);

I tried to insert it in a php file but in this case nothing happen :\

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Parametri da inserire per collegarsi al DB
$servername = "localhost";
$username = "username";
$password = "password";
$database = "database_name";
$options = [MYSQLI_OPT_LOCAL_INFILE => true];
$conn = mysqli_connect($servername, $username, $password, $database);
$conn->options(MYSQLI_OPT_LOCAL_INFILE, true);

if (!$conn) {
die("Connessione al database fallita: " . mysqli_connect_error());
}

// Query SQL
$query = "USE database_name;
TRUNCATE items_temp;

LOAD DATA LOCAL INFILE '/home/itoffice/data_bridge/items.txt'
INTO TABLE items_temp
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(id_tc_anartic, cod_art, desc_art, ump, umi, coef_ump_umi, gest_maga,
cod_iva, cod_cat_cont, desc_cat_cont, cod_class_pat, art_stato,
disabilitato, ean, peso_netto, peso_lordo, um_peso, lunghezza,
larghezza, altezza, diametro, cod_cat01, desc_cat01, cod_cat02,
desc_cat02, cod_cat03, desc_cat03, cod_cat04, desc_cat04, cod_cat05,
desc_cat05, cod_cat06, desc_cat06, cod_cat07, desc_cat07, cod_cat08,
desc_cat08, cod_cat09, desc_cat09, cod_cat10, desc_cat10, cod_cat11,
desc_cat11, cod_cat12, desc_cat12, cod_cat13, desc_cat13, cod_cat14,
desc_cat14, cod_cat15, desc_cat15, cod_cat16, desc_cat16, cod_cat17,
desc_cat17, cod_cat18, desc_cat18, cod_cat19, desc_cat19, cod_cat20,
desc_cat20, dt_creazione, dt_last_upd)";

if (mysqli_multi_query($conn, $query)) {
echo "Query eseguita con successo.";
} else {
echo "Errore nell'esecuzione della query: " . mysqli_error($conn);
}

mysqli_close($conn);
?>

I opened the php.ini file and I have:

; Allow accessing, from PHP's perspective, local files with LOAD DATA
statements
; https://php.net/mysqli.allow_local_infile
mysqli.allow_local_infile = On

Regards.
^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<kqhrnhFtbq5U2@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=114&group=comp.databases.mysql#114

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: use...@example.net (J.O. Aho)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 15:57:53 +0100
Lines: 25
Message-ID: <kqhrnhFtbq5U2@mid.individual.net>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<kqhf2pFtbq4U1@mid.individual.net> <ui0ae6$27ame$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net HoN2SajGQB2TneIWL2cNGQtkz1R+InJLqB94CCcT4iUJOPxt2I
Cancel-Lock: sha1:9LEBaWEIHEySYncU5RnoB717tmE= sha256:mchKvtVeNl9sBnDHg8FwKoMqcQWAEn5kBxJxF+nfnoQ=
User-Agent: Mozilla Thunderbird
Content-Language: en-US-large
In-Reply-To: <ui0ae6$27ame$1@dont-email.me>
 by: J.O. Aho - Thu, 2 Nov 2023 14:57 UTC

On 02/11/2023 15.07, ^Bart wrote:
>> */5 * * * * (root) (/usr/bin/mysql -umy_username -pmy_password
>> databasename <
>>   /home/itoffice/query.sql)
>
> */5 * * * * (itoffice) (/usr/bin/mysql -u username -p password db_name <
> /home/it_office/query.sql)
>
> It doesn't work :\ but it doesn't work also if I insert it in a php
> script; here below is the working *.sql file used from MariaDB CLI:

What error mail is sent from crontab? should be sent to the local
machines root user unless you have set MAILTO to another email address.

in worst case use less and read the /var/spool/mail/root should be in
the end of the file.
sure you can use the alpine or mutt to read the mail too.

By the way, do you have characters like '#;" in your password? Those
tend to cause issues when using this way. I would recommend the usage of
profile.

--
//Aho

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui0he6$29ikj$1@jstuckle.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=115&group=comp.databases.mysql#115

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: stuckle....@gmail.com (Jerry Stuckle)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Thu, 2 Nov 2023 12:06:12 -0400
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <ui0he6$29ikj$1@jstuckle.eternal-september.org>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Nov 2023 16:06:31 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="be9ecdc4435fcba1b9c1c645d09c67ad";
logging-data="2411155"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Aioq+XTF9udRKmH1rVajVtdj/QwWiywQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:54s0mpgHC1BQpNreQzlsC6www2E=
In-Reply-To: <uhvun1$256tt$1@dont-email.me>
Content-Language: en-US
 by: Jerry Stuckle - Thu, 2 Nov 2023 16:06 UTC

On 11/2/2023 6:46 AM, ^Bart wrote:
>> Thanks for your reply, I used PHP years and years ago and I don't
>> remember it very well but really thanks to share this solution! :)
>
> I did in my crontab this:
>
> */5 * * * * /usr/bin/mysql -u my_username -h localhost -p my_password <
> /home/itoffice/query.sql
>
> It doesn't work... :/
>
> If I run query.sql after I did a manual login in MariaDB it works.
>
> I think I must use php like what this site said:
> https://stackoverflow.com/questions/9948220/how-can-i-set-a-crontab-to-execute-a-mysql-query-and-log-the-output
>
> I think also I should save php file not in my home folder like
> /home/itoffice but in /var/www/html right?
>
> ^Bart
>

No space between your -p and your password. This is different from
other parameters.

--
==================
Remove the "x"'s from my email address
Jerry Stuckle
stucklex.jerryx@gmail.com
==================

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui30rp$2qj1q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=116&group=comp.databases.mysql#116

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Fri, 3 Nov 2023 15:42:01 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ui30rp$2qj1q$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 14:42:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a999e8b49749b0ce994fe81d19075353";
logging-data="2968634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KIs8/VKasMhfWXcrQV+BjdGrTiGPn9/w="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rYXiTC3GvvtrRNdIqlyYEWQTVoM=
Content-Language: en-US
In-Reply-To: <ui0he6$29ikj$1@jstuckle.eternal-september.org>
 by: ^Bart - Fri, 3 Nov 2023 14:42 UTC

> No space between your -p and your password.  This is different from
> other parameters.

You got the point, it works without space from -p and password but...

It works from command line:
$ mysql -u MY_USER -pMY_PASSWORD < /home/itoffice/query.sql

It doesn't work from crontab -e also from root:
*/5 * * * * -u MY_USER -pMY_PASSWORD < /home/itoffice/query.sql

I don't know why... :\

^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui3834$2rqcr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=117&group=comp.databases.mysql#117

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tnp...@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Fri, 3 Nov 2023 16:45:24 +0000
Organization: A little, after lunch
Lines: 24
Message-ID: <ui3834$2rqcr$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
<ui30rp$2qj1q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 16:45:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="31f303fe030e5e9d86bfd1a0a9b6e4b3";
logging-data="3008923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rMuyOqnPtIc5GOGCixNYkb20nXevdguI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZWSAUQ6Y5Utywr6z2UlnXurcD+E=
In-Reply-To: <ui30rp$2qj1q$1@dont-email.me>
Content-Language: en-GB
 by: The Natural Philosop - Fri, 3 Nov 2023 16:45 UTC

On 03/11/2023 14:42, ^Bart wrote:
>> No space between your -p and your password.  This is different from
>> other parameters.
>
> You got the point, it works without space from -p and password but...
>
> It works from command line:
> $ mysql -u MY_USER -pMY_PASSWORD < /home/itoffice/query.sql
>
> It doesn't work from crontab -e also from root:
> */5 * * * * -u MY_USER -pMY_PASSWORD < /home/itoffice/query.sql
>
> I don't know why... :\
>
perhaps adding 'mysql' would help?

> ^Bart
>

--
"Nature does not give up the winter because people dislike the cold."

― Confucius

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui505g$39s7l$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=118&group=comp.databases.mysql#118

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: non...@none.it (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Sat, 4 Nov 2023 09:42:13 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ui505g$39s7l$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
<ui30rp$2qj1q$1@dont-email.me> <ui3834$2rqcr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 08:42:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7889f48b8a4a41c4c945e929308d1f50";
logging-data="3469557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1900XxA75D4pL8FhO9Hb4AhLjcdaYY/whU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:yqflkjlhLDhvuI9ARQfIR1TzLW4=
In-Reply-To: <ui3834$2rqcr$1@dont-email.me>
Content-Language: en-US
 by: ^Bart - Sat, 4 Nov 2023 08:42 UTC

> perhaps adding 'mysql' would help?
>

I did it but I didn't past it on my reply! :)

I also inserted the full path of Mysql but... nothing appened...

^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<kqmg25Ftbq5U3@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=119&group=comp.databases.mysql#119

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: use...@example.net (J.O. Aho)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Sat, 4 Nov 2023 10:09:25 +0100
Lines: 21
Message-ID: <kqmg25Ftbq5U3@mid.individual.net>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
<ui30rp$2qj1q$1@dont-email.me> <ui3834$2rqcr$1@dont-email.me>
<ui505g$39s7l$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 3/B+P2uEXezCWU6HeuYgdAupigw11QYX1fBcZGlFx1NY5lN380
Cancel-Lock: sha1:aJpi3i00Kgur5TRO1LsMb4IeVis= sha256:TE8Mz1qgBwWJ0VxKm0nH8iFX+M+QjJdjpyYkPM3R13k=
User-Agent: Mozilla Thunderbird
Content-Language: en-US-large
In-Reply-To: <ui505g$39s7l$1@dont-email.me>
 by: J.O. Aho - Sat, 4 Nov 2023 09:09 UTC

On 04/11/2023 09.42, ^Bart wrote:
>> perhaps adding 'mysql' would help?
>>
>
> I did it but I didn't past it on my reply! :)
>
> I also inserted the full path of Mysql but... nothing appened...

Did you look at the mail from crontab? by default it goes to the
localhost root user (you can change that with setting the MAILTO
variable), if something wen t wrong while running the mysql command it
will be in that mail (if no output, no mail).

You could check your /var/log/mysql/mysql.{err,log} too

I hope the "-u MY_USER" was a typo, otherwise loose the space after '-u'.

--
//Aho

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui5t3r$3escc$1@jstuckle.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=120&group=comp.databases.mysql#120

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: stuckle....@gmail.com (Jerry Stuckle)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Sat, 4 Nov 2023 12:56:23 -0400
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ui5t3r$3escc$1@jstuckle.eternal-september.org>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
<ui30rp$2qj1q$1@dont-email.me> <ui3834$2rqcr$1@dont-email.me>
<ui505g$39s7l$1@dont-email.me> <kqmg25Ftbq5U3@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 16:56:27 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="e83a0b4d3a5f80f34523e34dbf47ae0d";
logging-data="3633548"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sniP4Z8F+7rpH7+gUC+D2G/b3kBfeFuc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rTVJ+tDi6ozuEJ48PYkt0/e8Jok=
Content-Language: en-US
In-Reply-To: <kqmg25Ftbq5U3@mid.individual.net>
 by: Jerry Stuckle - Sat, 4 Nov 2023 16:56 UTC

On 11/4/2023 5:09 AM, J.O. Aho wrote:
> On 04/11/2023 09.42, ^Bart wrote:
>>> perhaps adding 'mysql' would help?
>>>
>>
>> I did it but I didn't past it on my reply! :)
>>
>> I also inserted the full path of Mysql but... nothing appened...
>
> Did you look at the mail from crontab? by default it goes to the
> localhost root user (you can change that with setting the MAILTO
> variable), if something wen t wrong while running the mysql command it
> will be in that mail (if no output, no mail).
>
> You could check your /var/log/mysql/mysql.{err,log} too
>
> I hope the "-u MY_USER" was a typo, otherwise loose the space after '-u'.
>

The space after the -u is fine. It's only the password that can't have
the space.

--
==================
Remove the "x"'s from my email address
Jerry Stuckle
stucklex.jerryx@gmail.com
==================

Re: From bash script (Debian Bookworm) login and query to MariaDB

<ui7qe2$3uuvf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=121&group=comp.databases.mysql#121

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gabriele...@hotmail.com (^Bart)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Sun, 5 Nov 2023 11:23:51 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <ui7qe2$3uuvf$1@dont-email.me>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
<ui30rp$2qj1q$1@dont-email.me> <ui3834$2rqcr$1@dont-email.me>
<ui505g$39s7l$1@dont-email.me> <kqmg25Ftbq5U3@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 5 Nov 2023 10:22:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e17554625035dc807cc321cf476557a1";
logging-data="4160495"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Bsh3FEeLylgWxQynQ13Uaunv9zDmcnNw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6SyDDhHZxLCbIJJQIAXNSPNy7Rw=
Content-Language: en-US
In-Reply-To: <kqmg25Ftbq5U3@mid.individual.net>
 by: ^Bart - Sun, 5 Nov 2023 10:23 UTC

> Did you look at the mail from crontab? by default it goes to the
> localhost root user (you can change that with setting the MAILTO
> variable), if something wen t wrong while running the mysql command it
> will be in that mail (if no output, no mail).
>
> You could check your /var/log/mysql/mysql.{err,log} too
>
> I hope the "-u MY_USER" was a typo, otherwise loose the space after '-u'.

I found this solutions:

*/5 * * * * /home/itoffice/job01.sh

This is job01.sh

#!/bin/bash
#sostituisce tutte le virgole presenti nel file con dei punti
sed -i -e 's/,/./gip' /home/itoffice/data_bridge/articoli.txt

/usr/bin/mysql -umy_username -pmy_password < /home/itoffice/articoli.sql

#copia del file importato nella directory di backup
mv -v /home/itoffice/data_bridge/articoli.txt
"/home/itoffice/data_bridge_bck/articoli_$(date +"%d-%m-%Y_%H-%M".txt)"

I found these information to fix php load data:

https://itecnote.com/tecnote/php-load-data-local-infile-forbidden-after-php-mariadb-update/
https://itecnote.com/tecnote/php-load-data-local-infile-forbidden-after-php-mariadb-update/

But now I need to do other things in my company so... I know it's a
dirty way to use a *.sh file but I dont't have free time to fix it maybe
next weeks... ;)

Have a nice day!
^Bart

Re: From bash script (Debian Bookworm) login and query to MariaDB

<kqpe7cF4dqaU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=122&group=comp.databases.mysql#122

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: use...@example.net (J.O. Aho)
Newsgroups: comp.databases.mysql
Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB
Date: Sun, 5 Nov 2023 12:56:28 +0100
Lines: 37
Message-ID: <kqpe7cF4dqaU1@mid.individual.net>
References: <uhr78k$13p7r$1@dont-email.me> <uhrmcl$16ilv$2@dont-email.me>
<uhvn6g$23nq2$1@dont-email.me> <uhvun1$256tt$1@dont-email.me>
<ui0he6$29ikj$1@jstuckle.eternal-september.org>
<ui30rp$2qj1q$1@dont-email.me> <ui3834$2rqcr$1@dont-email.me>
<ui505g$39s7l$1@dont-email.me> <kqmg25Ftbq5U3@mid.individual.net>
<ui7qe2$3uuvf$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 2caRJVdnh5WHEZcKaX07OQlDU54y1Rkb53ZO37UQD/krOyEOz6
Cancel-Lock: sha1:qXwVPeLpbpmiJsYnONe7t7ZK7BM= sha256:23Inxy3DlsrBeAamWbdO3mTdacvENPaiPRnAJXzbyy0=
User-Agent: Mozilla Thunderbird
Content-Language: en-US-large
In-Reply-To: <ui7qe2$3uuvf$1@dont-email.me>
 by: J.O. Aho - Sun, 5 Nov 2023 11:56 UTC

On 05/11/2023 11:23, ^Bart wrote:
>> Did you look at the mail from crontab? by default it goes to the
>> localhost root user (you can change that with setting the MAILTO
>> variable), if something wen t wrong while running the mysql command it
>> will be in that mail (if no output, no mail).
>>
>> You could check your /var/log/mysql/mysql.{err,log} too
>>
>> I hope the "-u MY_USER" was a typo, otherwise loose the space after '-u'.
>
> I found this solutions:
>
> */5 * * * * /home/itoffice/job01.sh
>
> This is job01.sh
>
> #!/bin/bash
> #sostituisce tutte le virgole presenti nel file con dei punti
> sed -i -e 's/,/./gip' /home/itoffice/data_bridge/articoli.txt

Yes, the root will not have the same LANG settings as your user and
those you need to change the comma to full stop for decimal values.
You could have added the same LANG/LC to the cron and this hadn't been a
issue.

> But now I need to do other things in my company so... I know it's a
> dirty way to use a *.sh file but I dont't have free time to fix it maybe
> next weeks... ;)

Tend to become one of those things that will be never fixed and next
time another ad-hoc solution is used to fix next issue.

--
//Aho

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor