Groups | Search | Server Info | Login | Register
Groups > comp.databases.mysql > #7664
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | comp.databases.mysql |
| Subject | Re: From bash script (Debian Bookworm) login and query to MariaDB |
| Date | 2023-11-01 08:04 +0100 |
| Message-ID | <kqebjoFam3fU1@mid.individual.net> (permalink) |
| References | <uhr78k$13p7r$1@dont-email.me> |
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
Back to comp.databases.mysql | Previous | Next — Previous in thread | Next in thread | Find similar
From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-10-31 16:42 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB The Natural Philosopher <tnp@invalid.invalid> - 2023-10-31 20:00 +0000
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-02 09:39 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-02 11:46 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB "J.O. Aho" <user@example.net> - 2023-11-02 12:22 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-02 15:07 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB "J.O. Aho" <user@example.net> - 2023-11-02 15:57 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB Jerry Stuckle <stuckle.jerry@gmail.com> - 2023-11-02 12:06 -0400
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-03 15:42 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB The Natural Philosopher <tnp@invalid.invalid> - 2023-11-03 16:45 +0000
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <none@none.it> - 2023-11-04 09:42 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB "J.O. Aho" <user@example.net> - 2023-11-04 10:09 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB Jerry Stuckle <stuckle.jerry@gmail.com> - 2023-11-04 12:56 -0400
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-05 11:23 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB "J.O. Aho" <user@example.net> - 2023-11-05 12:56 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB Marco Moock <mm+usenet-es@dorfdsl.de> - 2023-10-31 21:01 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-02 09:40 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB Jerry Stuckle <stuckle.jerry@gmail.com> - 2023-10-31 19:06 -0400
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-02 09:50 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB "J.O. Aho" <user@example.net> - 2023-11-02 12:03 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB "J.O. Aho" <user@example.net> - 2023-11-01 08:04 +0100
Re: From bash script (Debian Bookworm) login and query to MariaDB ^Bart <gabriele1NOSPAM@hotmail.com> - 2023-11-02 10:09 +0100
csiph-web