Groups | Search | Server Info | Login | Register


Groups > comp.databases.mysql > #7670

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

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-02 12:03 +0100
Message-ID <kqhdvhFtbq5U1@mid.individual.net> (permalink)
References <uhr78k$13p7r$1@dont-email.me> <uhs1am$189pa$1@jstuckle.eternal-september.org> <uhvnrk$23sgb$1@dont-email.me>

Show all headers | View raw


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

Back to comp.databases.mysql | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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