MYSQL Installation and 0 basics using specific explanations

Source: Internet
Author: User
Tags administrator password

1. Sudo apt-get install mysql-server, input Administrator password, ' 123 '


2. Enter MySQL promot command line, ' mysql-u root-p ', input password


3. Create DATABASE "CREATE database xoops;"


4. Consent to root remote login: From all hosts: Grant all privileges on * * to [email protected] "%" identified by "Passw0rd" with GRANT option;


5. Build the database and create the user:

1) Build database: Create DATABASE test1;

2) Build user, Empower: Grant all privileges on test1.* to [email protected] "%" identified by "Passw0rd" with GRANT option;

3) Delete databases: Drop database test1;

6. Delete permissions:

1) Revoke all privileges in test1.* from [email protected] "%";

2) use MySQL;

3) Delete from user where user= "root" and host= "%";

4) flush privileges;

8. Show all databases: show databases; Show all tables in the library: show tables;


9. telnet mysql:mysql-h ip-u user-p


10. Backup and Recovery

Backing 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

Recovery database: Mysql-uroot-p < Name.sql

Recovery table: Mysql-uroot-p dbname < Name.sql (database must be specified)

Sample: Create a database table Mysql>create IF not EXISTS my_db default charset UTF8 COLLATE utf8_general_ci;

#注意后面这句话 "COLLATE utf8_general_ci", which roughly means sorting according to UTF8 format.

#那么在这个数据库下创建的全部数据表的默认字符集都会是utf8了

Mysql>create table my_table (name varchar () NOT NULL default ') Type=myisam default CharSet UTF8; #这句话就是创建一个表了, set the default character set to 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 Installation and 0 basics using specific explanations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.