mysql versions code example

Example 1: mysql version

# console
mysql --version
mysql -V

# sql query
SHOW VARIABLES LIKE%version%;

Example 2: what is my mysql version

Mysql version
mysql -V

Example 3: mysql version

mysqld --version

Example 4: mean mysql

avg(column)

Example 5: python and mysql connectivity

import pymysql

############### CONFIGURE THIS ###################
# Open database connection
db = pymysql.connect("database_host","username","password","database_name")
##################################################

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print ("Database version : {0}".format(data))

# disconnect from server
db.close()

Tags:

Php Example