MySql 安裝及0基礎使用具體解釋

來源:互聯網
上載者:User

標籤: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基礎使用具體解釋

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.