Python Forum
Warning password insecure - Mysql backup with Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Warning password insecure - Mysql backup with Python
#1
I made this little script with Python to create a backup of a table from my database:

import subprocess
sql_cmd = 'mysql -B -uUser -p password database -e "SELECT * FROM device;" > file.csv'
subprocess.run([sql_cmd], shell=True)
It is working, but I got this warning message:

mysql: [Warning] Using a password on the command line interface can be insecure.

I would like to solve this problem if someone can help me please Smile

Thanks ^^
Reply
#2
OS?..
Quote:The message is too short. Please enter a message longer than 5 characters.
Next time I will add periods like that
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
That looks like a MySQL warning. You could try a way to securely store the password.
Reply
#4
Instead of using subprocess to invoke the command line client, you could use a mysql api to query the database directly. That would eliminate the "password using command line" issue.
Reply
#5
As mention bye @nilamo there are tool for this in Python to connect directly.
PyMySQL pure-Python MySQL client library
mysqlclient
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 716 Oct-03-2023, 10:25 PM
Last Post: lostintime
  help me to make my password list in python >>> Oktay34riza 0 595 Dec-23-2022, 12:38 PM
Last Post: Oktay34riza
Big Grin My backup is not complete - SSH Paramiko Braulio 2 1,069 Jul-28-2022, 06:30 PM
Last Post: Braulio
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,205 Feb-09-2022, 09:55 AM
Last Post: ibreeden
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,737 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  How to take the tar backup files form remote server to local server sivareddy 0 1,931 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Python and MySql ogautier 8 3,411 May-20-2021, 11:10 PM
Last Post: Pedroski55
  Python and MySQL Pedroski55 5 3,260 Mar-23-2021, 06:40 AM
Last Post: ndc85430
  Python MySQL ogautier 0 2,121 Sep-03-2020, 03:54 PM
Last Post: ogautier
  Insert into mysql through python LaKhWaN 0 1,957 Aug-26-2020, 04:54 AM
Last Post: LaKhWaN

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020