PG Certificate Course in Data Science, AI & Machine Learning by IIT Roorkee. Apply Now & Get up to Rs. 75,000 OFF! Offer Ends in:

  Apply Now

SQL Tutorial

68 / 68

Getting database information

Once you connect to MySQL Server and/or switch to a database, and you may use various commands to get information about database environment and your session.

  • Current userid and local hostname
  • Connection Id to database
  • Database name you are connected to
  • MySQL Server version
  • List of all databases in MySQL Server
  • MySQL Server port
    SHOW VARIABLES WHERE Variable_name = 'port';
  • MySQL Server hostname
    SHOW VARIABLES WHERE Variable_name = 'hostname';

All information in one go using 'status' command

  • MySQL [retail_db]> status
    mysql Ver 15.1 Distrib 5.5.47-MariaDB, for Linux (x86_64) using readline 5.1

    Connection id: 25175
    Current database: retail_db
    Current user: sqoopuser@ip-172-##-##-179.ec2.internal
    SSL: Not in use
    Current pager: stdout
    Using outfile: ''
    Using delimiter: ;
    Server: MySQL
    Server version: 5.6.30 MySQL Community Server (GPL)
    Protocol version: 10
    Connection: ip-172-##-##-154 via TCP/IP
    Server characterset: latin1
    Db characterset: latin1
    Client characterset: utf8
    Conn. characterset: utf8
    TCP port: 3306
    Uptime: 81 days 14 hours 57 min 30 sec

    Threads: 25 Questions: 2214929171 Slow queries: 258 Opens: 217072 Flush tables: 1 Open tables: 431 Queries per second avg: 314.074

    MySQL [retail_db]>

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...