MySQL Quick Start

Source: Internet
Author: User
Tags mysql host

MySQL Quick Start 1. Connect to MySql and use the installed MySQLl command line. By default, the user is a root user. Here, I use the dos command line to log on. 1. Connect to the local MySQL format: mysql-u user name-p User Password example: mysql-uroot-padmin 2. connect to a remote MySQL format: mysql [-h host address]-u user name-p User Password example: mysql-h192.168.24. *-uroot-padmin 3. exit format: exit example: exit 2. Create user 1. Add a user named test1 with the password test1 so that the user can log on to any machine and only have the permission to add, delete, modify, and query test. Format: grant permission on database. * to username @ login host identified by "password" Example: grant select, insert, update, delete on test. * test1 @ "%" identified by "test1 ". 2. Add a user named test2 with the password test2 so that the user can log on locally and have the permission to add, delete, modify, and query all databases. Format: grant permission on database. * to username @ login host identified by "password" Example: grant select, insert, update, delete on *. * test2 @ localhost identified by "test2 ". In this way, the data can only be accessed through the web pages on the MySQL host, making the data more secure. Iii. operations on the database 1. Display Command Format: show project to be displayed (can be databases tables, etc.), select project to be displayed () (can be user, version, etc) desribe: displays the current database version: select virsion (); displays the current user: select user (); displays all users: select user from mysql. user; show all databases: show databases; show tables: show tables; show table details: desc [ribe] tablename; 2. Open Database Format: use databasename; example: use test; 3. database addition and deletion format: create/drop database databasename instance: Add a database: create database test1; delete a database: drop Database test1; 4. Example of adding, deleting, modifying, and querying a table: Add a table: create table teacher (id int (3), name char (10) not null, address varchar (50); delete a table: drop table teacher; Add table data: insert into table Name (column name) values (value); Update table data: update table name set field 1 = 'A', Field 2 = 'B'; delete table data: delete from teacher [where...] import SQL Script :\. full file path or full source file path 4. database backup, no matter which database management system is a hot topic. Data first makes the database management systems the same, regardless of the differences. It only indicates whether the function is powerful or not, and whether the encapsulation is complete (we recommend that you do not use the unique features of the database ). For example, in Oracle, cascade deletion does not need to write the trigger on its own, but auto-incrementing sequence is so troublesome in Oracle. 1. Back up the entire database: mysqldump-uroot-padmin test> c: \ out. SQL 2. Export a table: mysqldump-uroot-padmin test teacher> c: \ out. SQL 5. Conclusion I believe that with the above section, you can operate MySQL with ease. In addition, MySQL supports multi-line Input. You only need to enter ";" in the last line, for example, insert into t_user (userId, password, username) values ('admin', 'admin', 'zhang san ');
 

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.