標籤:http os 使用 io ar 資料 art div html
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. 同意root遠程登陸: 從全部主機:grant all privileges on *.* to [email protected]"%" identified by "passw0rd" with grant option;
5. 建資料庫,建立user:
1) 建庫:create database test1;
2) 建使用者,賦權:grant all privileges on test1.* to [email protected]"%" identified by "passw0rd" with grant option;
3) 刪除資料庫:drop database test1;
6. 刪除許可權:
1) revoke all privileges on test1.* from [email protected]"%";
2) use mysql;
3) delete from user where user="root" and host="%";
4) flush privileges;
8. 顯示全部的資料庫:show databases; 顯示庫中全部的表:show tables;
9. 遠程登入mysql:mysql -h ip -u user -p
10. 備份和恢複
備份單個資料庫:mysqldump -uroot -p -B dbname > dbname.sql
備份所有資料庫:mysqldump -uroot -p --all-databases > all.sql
備份表: mysqldump -uroot -p -B dbname --table tablename > tablename.sql
恢複資料庫:mysql -uroot -p < name.sql
恢複表:mysql -uroot -p dbname < name.sql (必須指定資料庫)
11. Sample:建立資料庫表 mysql>CREATE DATABASE IF NOT EXISTS my_db default charset utf8 COLLATE utf8_general_ci;
#注意後面這句話 "COLLATE utf8_general_ci",大致意思是在排序時依據utf8變碼格式來排序
#那麼在這個資料庫下建立的全部資料表的預設字元集都會是utf8了
mysql>create table my_table (name varchar(20) not null default ‘‘)type=myisam default charset utf8; #這句話就是建立一個表了,制定預設字元集為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)
MySql 安裝及0基礎使用具體解釋