![]() ![]() MySQL has stand-alone clients that allow users to interact directly with a MySQL database using SQL, but more often, MySQL is used with other programs to implement applications that need relational database capability. In 2010, when Oracle acquired Sun, Widenius forked the open-source MySQL project to create MariaDB. MySQL was owned and sponsored by the Swedish company MySQL AB, which was bought by Sun Microsystems (now Oracle Corporation). MySQL is free and open-source software under the terms of the GNU General Public License, and is also available under a variety of proprietary licenses. In addition to relational databases and SQL, an RDBMS like MySQL works with an operating system to implement a relational database in a computer's storage system, manages users, allows for network access and facilitates testing database integrity and creation of backups. SQL is a language that programmers use to create, modify and extract data from the relational database, as well as control user access to the database. A relational database organizes data into one or more data tables in which data may be related to each other these relations help structure the data. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. ![]() MySQL ( / ˌ m aɪ ˌ ɛ s ˌ k juː ˈ ɛ l/) is an open-source relational database management system (RDBMS). See complete examples in our GitHub repository.Linux, Solaris, macOS, Windows, FreeBSD #Get all the rows from a table, for example account tableĪll_vals=$(runQuery "select * from account")įinally, run the test.sh file to test/use the database and see the output: $ bash test.shĪlso, see file manipulation and how to Find file in Linux. #loop through the tables field and print all database tables #Call the runQuery function from the perform_db_operation.sh file Test or run the database queries by calling the functions from the file perform_db_operation.sh using the test.sh file: #!/bin/bash Mysql -u"$DB_USER" -p"$DB_PASS_ORG" -database $DB_NAME -se "$QUERY" | while read -r result ģ. #checking/validating the database connection paramĮcho "Error:: No database query string is supplied!" #Converting base64 encripted password to the original passwordĭB_PASS_ORG=`echo "$DB_PASSWD" | base64 -decode` Validation of database configuration parameters and performing database operations: perform_db_operation.shĮcho "Error:: No configuration file is found at the '$CWD' directory."Įcho "Error:: No database host is supplied."Įcho "Error:: No database name is supplied."Įcho "Error:: No database username is supplied."Įcho "Error:: No database password is supplied." Making Database Connection and Error HandlingĢ. However, it’s still important to take additional security measures, such as limiting access to the script file and the database itself, to ensure the password is not compromised. ![]() By using base64 encoding, the password is not readable in plain text and provides some level of security. ![]() □Note: It’s important to keep the password secure by not storing it in plain text in the script. To generate a base64-encoded password, you can use the echo command to input your password (without the quotes) and pipe it to the base64 command, which will output the encoded string. The fourth line sets the variable DB_PASSWD to the base64-encoded password that will be used to authenticate the user. This shell scripting code sets variables for the database name, host, user, and password to be used in accessing a MySQL/MariaDB database using Linux shell scripting. #To genearte base64 encripted password, run command: echo -n "your-password" | base64 Defile the database configuration parameters like the config.yaml file DB_NAME='' Save the following files with the content in the same working directory.ġ. We will have three different files, config.yaml for saving the database configurations, perform_db_operation.sh for having different functions for the validations of the database configuration parameters and running the actual database queries, and finally test.sh file to call the functions available in the perform_db_operation.sh file. Making Database Connection and Error Handling. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |