1. sudo apt-get install mysql-server, input administrator password, '123'
2. enter mysql promot in command line, 'mysql-u root-p', input password
3. create database "create database xoops ;"
4. allow root remote login: grant all privileges on *. * to root @ "%" identified by "passw0rd" with grant option;
5. Create a database and create a user:
1) database creation: create database test1;
2) create a user and grant permissions: grant all privileges on test1. * to user_test @ "%" identified by "passw0rd" with grant option;
3) delete a database: drop database test1;
6. delete permissions:
1) revoke all privileges on test1. * from test1 @ "% ";
2) use mysql;
3) delete from user where user = "root" and host = "% ";
4) flush privileges;
8. display all databases: show databases; display all tables in the database: show tables;
9. remotely log on to mysql: mysql-h ip-u user-p
10. backup and recovery
Back up a single database: mysqldump-uroot-p-B dbname> dbname. SQL
Back up all databases: mysqldump-uroot-p -- all-databases> all. SQL
Backup table: mysqldump-uroot-p-B dbname -- table tablename> tablename. SQL
Recover Database: mysql-uroot-p <name. SQL
Recovery table: mysql-uroot-p dbname <name. SQL (the database must be specified)
11. Sample: CREATE a DATABASE table mysql> create database if not exists my_db default charset utf8 COLLATE utf8_general_ci;
# Pay attention to the following sentence "COLLATE utf8_general_ci", which roughly means sorting by utf8 variable code format during sorting
# The default character set of all data tables created in this database will be utf8.
Mysql> create table my_table (name varchar (20) not null default '') type = myisam default charset utf8; # This statement creates a table. The default character set is utf8.
C ++ sample code:
1. boost libary is required. "sudo apt-get install libboost-date-time-dev"
2. http://dev.mysql.com/tech-resources/articles/building-mysql-connector-cpp.html
3. create database FaceDB4. create table facetable (id INT, facename TEXT, username TEXT)