Note: It is generally a good idea to use All Caps on MySQL command so that you will not confuse the syntax between the actual MySQL command and the data/variables 7. To see all the data from a table mysql> SELECT * FROM your_table_name To see all the tables on a database mysql> SHOW TABLES To use/switch to a particular database mysql> USE your_database_name To see all the databases on the server mysql> SHOW DATABASES We need to login to the server before we use these commands. I will explain about MySQL command that we just used. */Īfter the last command, the inserted data will be shown like the following table. Connector/C++ takes care of freeing that. You must free the sql::Statement and sql::Connection objects explicitly using deleteīut do not explicitly free driver, the connector object. Stmt->execute( "INSERT INTO test(id, label) VALUES (1, 'a')") //insert into 'test' table with (1 and 'a') delete stmt "CREATE TABLE test(id INT, label CHAR(1))") //create table with (column name as id accepting INT) and (column name as label accepting CHAR(1)) Stmt->execute( "DROP TABLE IF EXISTS test") //drop if 'test' table exists Stmt->execute( "USE test_db") //set current database as test_db First, issue this command: sudo apt install mariadb-server. Stmt->execute( "CREATE DATABASE test_db") // create 'test_db' database In this part of the article we will be exploring on how to install MariaDB server on Raspberry Pi. Stmt->execute( "DROP DATABASE IF EXISTS test_db") //drop if 'test_db' exists */ # include "mysql_connection.h" # include # include # include # include using namespace std Ĭout connect( "tcp://127.0.0.1:3306", "root", "root") //IP Address, user name, password Headers from cppconn/ and mysql_driver.h + mysql_util.h * Standard C++ includes */ # include # include /* then: sudo apt-get install mysql-server nginx. ![]() Note: The default username is root $ mkdir MySQLTest Before you install, it is important to run update and upgrade sudo apt-get update sudo apt-get upgrade. Note: REMEMBER to change the ‘password’ to the root password of MySQL in the program. ![]() $ sudo apt-get install libmysqlclient-dev libmysqlcppconn-devįirst, create main.cpp program, copy the C++ program and save it. We will need to install this in order to insert/retrive data to/from a MySQL server with C++ language. Note: When you are installing MySQL, you will be asked for a root password. $ sudo apt-get install mysql-server php5-mysql ![]() We will first install the MySQL server on Raspberry Pi. How to install My SQL Connector/C++ on Raspberry Pi With Cmake 1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |