How to show a list of all databases in MySQL

When we work with a MySQL server, it is an everyday activity to view or list the databases, display the database table. The display of the user account information and privileges residing on the server.

Displaying MySQL Databases:

Open the MySQL Command Line Client that appears with a prompt for mysql>. First, use the password you created during the installation of MySQL to log into the MySQL database server. You are now linked to the host of the MySQL server, where all SQL statements can be executed. Finally, to list/show databases, run the SHOW Databases command.

The most popular way to get a list of MySQL databases is to connect to a MySQL server using the MySQL client and execute the Display DATABASES order.

Open the MySQL server using the following command and, when prompted, enter your MySQL user password:

mysql -u user -p

Utilizing schemas:

MySQL also allows one to list databases with another instruction, which is a Display SCHEMAS statement. This command is a Display DATABASES synonym and gives the same result.

SCHEMAS SHOW;

Displaying all MySQL databases:

You would need to log in as a user who can access all the databases to list all the databases on the MySQL server by default. The MySQL root user, or set a global privilege for Display DATABASES.

Log in to the root MySQL user:

mysql -u user -p

Run the DATABASES Display command:

DATABASES SHOW;

On the MySQL server, you can see a list of all the databases.

Database list using pattern matching:

The Display Databases command in MySQL also offers an alternative that allows us to filter the returned database by matching the LIKE and WHERE clauses with different patterns. The LIKE clause lists the name of the database that fits the pattern specified. More versatility is provided by the WHERE clause to list the SQL statement database that fits the specified condition.

Syntax:

The syntax for using pattern matching with the Display Databases command is as follows:

LIKE pattern Display DATABASES;

DISPLAY DATABASES WHERE the phrase is;

You can understand this with the following example where the percentage sign assumes zero, one, or several characters:

LIKE " percent schema" Display DATABASES;

The LIKE clause is often not sufficient; we can then conduct a more detailed search to query the information schema’s database information from the schema table. In MySQL, the information schema is a database of information to get the results using the command Display DATABASES.

FROM information schema.schema; SELECT schema name

With the Display DATABASES instruction, you can check how the WHERE clause is used. This statement returns the database whose name for the schema begins with ‘s’::

SELECT schema name FROM schema. Schema details WHERE schema name LIKE percentage;

Database list via command line:

You can use either the MySQL command with the -e option that stands for executing or the mysqlshow that shows database and table information. It is used to get a list of databases without logging in to the MySQL shell.

This is particularly useful when you want to work with shell scripts for your MySQL databases.

To present a list of all databases, run the following command on your terminal:

mysql -u user -p -e 'database display;'

The Conclusion:

Here, you have learned how to display or list tables in the MySQL database and use pattern matching to filter performance.

How to Run Cron Jobs Every 5, 10, or 15 Minutes

A cron job is work performed at given intervals. A minute, hour, Day of the month, month, Day of the week, or any combination may be scheduled to perform the tasks.

In general, Cron jobs are used to automate system maintenance or management, such as backing up databases or records, updating the system with the latest security updates, checking the use of disk space, sending emails, etc.

Some of the most widely used cron schedules are running cron tasks. It executes in 5, 10, or 15 minutes intervals.

Syntax and Operators of Crontab

Crontab (Cron table) is a text file that specifies the cron work schedule. You can build, access, change and delete Crontab files with the crontab command.

each and every line holds six fields isolated by a space followed by the command to be executed:

* * * * * command(s)

^ ^ ^ ^ ^

| | | | |     allowed values

| | | | |     -------

| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)

| | | ------- Month (1 - 12)

| | --------- Day of month (1 - 31)

| ----------- Hour (0 - 23)

------------- Minute (0 - 59)

It also accepts the following operators for the five fields at the beginning (time and date):

* – Asterisks as an operator means it allows all the values. If you have the asterisk symbol in the Minute sector, every Minute, the task is performed.

– – The hyphen operator allows several values to be defined. If you set 1-5 in the Day of the Week box, the task will run weekly (From Monday to Friday). The set is inclusive, which means that the range contains the first and last values.

, – The comma operator helps you to identify the repetition list of values. If you have 1,3,5in the Hour area, the task will run at 1 am, 3 am, and 5 am. The list can contain ranges and single values, 1-5,7,8,10-15

/ – You can use the slash operator to define phase values that can be used in combination with ranges. For, e.g., if you have 1-10/2 in the Minute’s sector, this means that the action is executed in the range 1-10 every two minutes, the same as specifying 1,3,5,7,9. Also, you can use the asterisk operator instead of a set of values. “You can use “*/20” to designate a job to be executed every 20 minutes.

The system-wide crontab file syntax varies slightly from that of user crontabs. This requires an additional mandatory user area defining which user is running the cron job.

* * * * * <username> instruction <username> (s)

Use the crontab -e command to modify the crontab file or build one if it doesn’t exist.

Run a job every 5 minutes with Cron

Every five minutes, there are two ways to run a cron job.

The first choice is to create a list of minutes using the comma operator:

0,5,10,15,20,25,30,35,40,45,50,55 * * * *Command

The above line is syntactically right, and it’s only going to work correctly. Typing the entire list might, however, be tedious and prone to mistakes.

The second choice for specifying a job to be done every 5 minutes is to use the phase operator:

*/5 * * * * Order * Command *

*/5 means that you create a list of all minutes and run the job from the list for every fifth value.

Run a job every 10 minutes with Cron

To run a cron job every 10 minutes, in the crontab code, add the following line:

*/10 * * * * command

Run a job with Cron every 15 minutes

To run a cron job every 15 minutes, in the crontab code, add the following line:

*/15 * * * * command

Learn How to Extract a (Unzip) tar.xz File

Tar allows one to extract and create tar archives. It maintains a vast range of compression programs such as gzip, bzip2, lzip, lzma, lzop, xz, and compress. The Xz algorithm is one of the most popular compression methods based on the LZMA algorithm. The name of a tar archive compressed with xz concludes with the string ‘tar’ and contains the string ‘xz.’The article explains how to use the tar command to unzip archives and use the unzip command.

Extracting tar.xz File

The tar utility is included in all Linux distros and macOS by default. To extract a tar.xz file, create a subdirectory in the current directory and input the tar command followed by the -x option.

$ tar –xf myfolder.tar.xz

Tar extracts archive by identifying the archive type. The same command is used to determine the archive type, such as .tar, .tar.gz, or .tar.bz2.For more robust output, use the -v flag. This option instructs tar to list the names of the files stored on the hard drive.

$ tar –xvf myfolder.tar.xz

For the automated extraction, archive contents are extracted from the working directory itself. To properly extract archived files, use the – directory parameter (-C)

Step-by-step guide to extracting the archive to the /home/test/files directory.

$ tar –xf myfolder.tar.xz -C /home/test/files

Extracting Specific Files from a tar.xz File

To extract the files from a tar.xz file, append space-separated names of files to be extracted to the end of the archive name:

$ tar –xf myfolder.tar.xz file1 file2

If you are extracting files, you must supply each file’s exact names, including where it was found. Extracting directories from an archive is similar to extracting files from an archive:

$ tar –xf myfolder.tar.xz folder1 folder2

If you attempt to extract a file that no longer exists, an error message will be displayed.

$ tar –xf myfolder.tar.xz README

No such file was found in the archive. Rejecting as bad because of previous problems. If specifying the —wildcards flag, you can extract files from a tar.xz file based on a wildcard pattern. The pattern must be quoted for it to be analyzed. For example, to extract only PNG ZIP files, you would use:

$ tar –xf myfolder.tar.xz —mycards '*.png'

Extracting tar.xz File from the stdin

When extracting a compressed tar.xz file by reading the archive from standard input (usually through piping), you must specify the decompression option. The -J option instructs tar that the file is compressed with the xz file format. We can use wget to download the Linux kernel using wget, and then we can use tar to extract the Linux kernel.

$ wget -c https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.5.3.tar.xz -O - | Sudo tar -xj

If you don’t specify the decompression format, the tar command will show you the appropriate format.

Tar: Archive is compressed. Use -J option

tar: Error is not recoverable: exiting now

Listing tar.xz File Content

To list the contents of a tarball, use the show the -t command.

$ tar –tf myfolder.tar.xz

The resulting outputs will look similar to this.

myfile1

myfile2

myfile3

When providing —verbose (-v), tar prints more information, such as file size and owner.

$ tar –tvf myfolder.tar.xz

-rw-r—r— test /user 0 2020-02-15 01:19 myfile1

-rw-r—r— test /user 0 2020-02-15 01:19 myfile2

-rw-r—r— test/user 0 2020-02-15 01:19 myfile3

Conclusion

Tar.xz file is a Tar archive compressed with xz. To extract a tar.xz file, use the tar -xf command, followed by the archive name.

show module fex

To verify hardware status on FEX on Cisco Nexus Operating System.

show environment fex 100                                                                                                                                                          


Temperature Fex 100:
-----------------------------------------------------------------
Module   Sensor     MajorThresh   MinorThres   CurTemp     Status
                    (Celsius)     (Celsius)    (Celsius)         
-----------------------------------------------------------------
1        Outlet-1   92            89           42          ok             
1        Outlet-2   76            68           38          ok             
1        Inlet-1    61            53           37          ok             
1        Die-1      92            85           48          ok             


Fan Fex: 100:
------------------------------------------------------
Fan             Model                Hw         Status
------------------------------------------------------
Chassis         N2K-C2232-FAN        --         ok
PS-1            N2200-PAC-400W       --         failure
PS-2            N2200-PAC-400W       --         ok

Power Supply Fex 100:
---------------------------------------------------------------------------
Voltage: 12 Volts
-----------------------------------------------------
PS  Model                Power       Power     Status
                         (Watts)     (Amp)           
-----------------------------------------------------
1   --                        --        --     fail/shutdown       
2   N2200-PAC-400W        396.00     33.00     ok                  


Mod Model                Power     Power       Power     Power       Status
                         Requested Requested   Allocated Allocated         
                         (Watts)   (Amp)       (Watts)   (Amp)               
--- -------------------  -------   ----------  --------- ----------  ----------
1    N2K-C2232TM-10GE    102.00    8.50        102.00    8.50        powered-up


Power Usage Summary:
--------------------
Power Supply redundancy mode:                 redundant

Total Power Capacity                              396.00 W

Power reserved for Supervisor(s)                  102.00 W
Power currently used by Modules                     0.00 W

                                                -------------
Total Power Available                             294.00 W
                                                -------------
Pearl-N5K-02#