C++ tutorial-C++ and Mysql database


Create sample database and tables

To create a sample database and tables that you will work with, please open your DOS window and type the following text to log into your database server as shown below:


c++ mysql login scree

In this tutorial, I use root user and root password to log in to my local database server (localhost). If you provided correct user and password, you will successfully log in to your server.

mysql correct password



Create sample database and tables

To create a sample database and tables that you will work with, please open your DOS window and type the following text to log into your database server as shown below:

-To create a sample database (e.g.dbstudent), please type the following command:

mysql>CREATE DATABASE dbstudent;

-To create a sample table (e.g. tblstudent) in this database, type:

mysql>USE dbstudent;

mysql>CREATE TABLE tblstudent(id varchar(5) not null,name varchar(20));

Now you have a database and a table created. Next, you will insert some data to the table that will be later retrieved by C or C++ code.

-To insert same test data type:

mysql>INSERT INTO tblstudent(id,name) VALUES('1 ', 'Dara Yuk ');



mysql>INSERT INTO tblstudent(id,name) VALUES('2 ', 'Khorn Channa ');

-To see your records in the table type:

mysql>SELECT * FROM tblstudent;


Comments




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.