In the above program, we included the mysql.h header file to use MySql connectivity related functions. Here, we created variables server, username, and password that are initialized values specific to the MySQL connectivity.
Here, we connected to the MySQL server and then created the MyDb database in the MySql server using mysql_query() function with specified SQL command and then print "Database created successfully" message on the console screen.
In this program, we will connect to the MySQL server and create the "MyDb" database in MySQL dynamically using the "Create database MyDb" command.
Program/Source Code:
The source code to create MySQL database dynamically in Linux is given below. The given program is compiled and executed successfully on Ubuntu 20.04.
Output:
In the above program, we included the mysql.h header file to use MySql connectivity related functions. Here, we created variables server, username, and password that are initialized values specific to the MySQL connectivity.
Here, we connected to the MySQL server and then created the MyDb database in the MySql server using mysql_query() function with specified SQL command and then print "Database created successfully" message on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer