MySQL Installation and basic operation

Source: Internet
Author: User

1. Installation & Configuration

Using Ubuntu 16.04 LTS operating system, directly using the Apt-get install Mysql-server installation, the middle needs the database root user's password, records well. Use Mysql-v to view the version after the installation is complete.

Modify/ETC/MYSQL/MYSQL.CONF.D/MYSQLD.CNF Comments The following statements are available for other machines to access.

# bind-address = 127.0.0.1

2. Create a database

Use Mysql-u root-p to connect to the local database, prompting for and entering the password.

@>mysql-u root-p

Creating a database with the CREATE command format: Create databases < database name >; ( note to ";" End )

MySQL >CREATE database testdb;

After completion, enter "show Database;" command to see the currently created database.

MySQL >show database;

3. Create user, authorize

Create User: Test

MySQL >insert into mysql.user (Host,user,password) VALUES ("localhost", "Test", Password ("123456"));

Give the test user the TestDB Library all table additions and deletions, and can be accessed from the local (statement '% ' meaning)

MySQL >grant all privileges in testdb.* to [email protected] '% ';
Mysql>flush privileges; Refresh System Permissions Table

4. Create a table

First switch to TestDB, create table by creating tables, complete support through show tables to view the list of tables in the library, describe view the structure of the specified table.

mysql> use TestDB;

Mysql>create TABLE User (name varchar, addr varchar (50));

Mysql>show tables;

Mysql>describe user;

5. Inserting data

Inserting data through SQL statements.

Mysql>insert into user (name, addr) values (' User1 ', ' first user ');

6. Query data

queries through SQL statements.

Resources:

Create database and database tables with MySQL: http://database.51cto.com/art/200511/12524.htm

MySQL Add user, delete user and authorization: http://www.cnblogs.com/wanghetao/p/3806888.html

MySQL Installation and basic operation

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.