ADVERTISEMENT
ADVERTISEMENT

C program to get MySQL client version in Linux

Here, we are going to write a C program to get MySQL client version in Linux.
Submitted by Nidhi, on February 13, 2021

Prerequisites:

The following packages need to be installed in the ubuntu machine for MySQL connectivity using the C program.

sudo apt install default-libmysqlclient-dev

Problem Solution:

In this program, we will get the MySQL client version in Linux and the print version on the console screen.

Program/Source Code:

The source code to get the MySQL client version in Linux is given below. The given program is compiled and executed successfully on Ubuntu 20.04.

//C program to get MySQL client version in Linux

#include <mysql.h>
#include <stdio.h>
#include <string.h>

int main()
{
    char ver[16] = { 0 };

    strcpy(ver, mysql_get_client_info());
    printf("MySQL client version is: %s\n", ver);

    return 0;
}

Output:

$ gcc version.c -o version  `mysql_config --cflags --libs`
$ ./version 
MySQL client version is: 8.0.23

In the above program, we included the mysql.h header file to use MySql connectivity related functions. Here, we got the version of the MySql client using mysql_get_client_info() and then print the result on the console screen.

C MySQL Programs »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.