MySQL Quick Start

Source: Internet
Author: User
Tags mysql client mysql command line

The recent use of free time to read the MySQL must know, for the MySQL foundation to understand more deeply. Before the main use of SQL Server development, so for MySQL do not know too much, feel the same, no need to learn, with the time to check on the line, but in fact, there are some drawbacks, is not a systematic understanding of MySQL, the mastery of things are relatively loose, the foundation is not firm. In fact, for each specialized knowledge, all need a systematic study, lay a good foundation, so as to learn some advanced topics in depth. Good people, like holding a map, can pinpoint themselves and find the path to the destination. and the foundation of the poor people, like headless flies blind hit, may also reach the destination, but the time will only be more.

Have not written a blog before, just read someone else's blog, learned a lot. There are blogs about the benefits of blogging, the benefits are really many, so I also want to experience, so took a little time to learn how to beautify the blog, my blog style is mainly from Ysocean, before he wrote the Java Related Development Framework blog, feel fresh, concise, clear, so audacity plagiarism, I hope he doesn't want to hit me, haha. No blog people have some things are not realized, of course, the so-called blog is to walk the heart of writing something, rather than write a title, will code a copy, ok a blog done, this may help you consult, but for the mastery of knowledge obviously has little effect. Walking the heart of writing a blog, the knowledge will be more solid, but also conducive to the construction of the entire knowledge framework. Well, do not tell the benefits of blogging, because I am also a beginner, or personally to understand it.

My first blog is to write the above mentioned MySQL, mainly based on the "MySQL must know will" a book, this book is mainly about the basic knowledge of MySQL, all aspects are involved, but some places speak relatively shallow, simple introduction, a pen, should find specialized books to study these advanced topics of knowledge. I would like to write this MySQL into a series, can be considered a reading summary, I will not be all the chapters of the record, mainly on SQL Server does not have or very little taste of the scenery.

1. mysql installation 1.1 download MySQL

Official: https://dev.mysql.com/downloads/mysql/, Download Community Edition

1.2 Installation

I downloaded the installation package directly, of course, can also download the decompression version, free installation, but need to manually configure, start the service and so on. Installation installation steps refer to http://jingyan.baidu.com/article/a17d528535dd808098c8f286.html, the installation version is different, but the installation is not the difference.

It is important to remember the root user's password, which is required when the client connects to the server.

2. mysql Client tool 2.1 MySQL command line client tool

This tool is stored in the installation directory bin, the file name is Mysql.exe program. Here's how to use this tool.

The first way: You can search MySQL through the window launch menu, find MySQL command line client, enter the root account password to connect to the local MySQL server.

The second way: via the command line, switch to the directory where Mysql.exe is located, then execute mysql-u root-p, then enter the root account password to log in. Of course this is also connected to the local server.

You can also connect to other MySQL servers via this client, mysql-h localhost-p 3306-u root-p databasename to connect to the others.

After-H is the machine name or IP

-P is the port number, default is 3306, note that this is the upper case P

DatabaseName If you fill it out, open the database directly after the connection. If you do not write, simply connect to the database server, there is no database open, open the specified database is described below.

The key point to say is: The default MySQL server is only native connection, if the need for the external network to connect properly. Need to set open permissions to the Mysql\user form, add the client IP that can be connected;

Additional command-line options and parameter lists are available for help;

Note that the command needs to be semicolon ";" or \g end, otherwise do not execute the command.

2.2 Third-party MySQL database connection tool

You can use Navicat for MySQL, which is a graphical interactive MySQL client tool. In addition Navicat Premium can also, this is a more common database client tool, can link MySQL, Oracle, Sqlsever and so on. Specific operation method can consult relevant information, there are other database graphics client operation experience can also explore their own use, similar.

3. mysql Command 3.1 use command

It was said that the MySQL server was connected through the client tool, but the database was not opened and the database could not be manipulated. To open the specified database, using the USE keyword, in order to use the test database, you should enter the command using test;

The students who understand SQL Server should know that when executing a script, the database is selected first and the use command is used, which is the same for two DBMS.

3.2 Show Command

The above mentioned the Open database, you need to enter the name of the database, but the specific name do not know what to do? The MySQL database server stores information such as databases, tables, columns, users, permissions, and so on in a database called MySQL, but does not recommend accessing these system tables directly, and can use the show command to obtain relevant information.

3.2.1 Viewing the list of databases on the server

show databases;

With this command you will see a list of all database names and then open the desired database with the previous use command.

3.2.2 Viewing all tables in a database

Show tables;

This command gets all the tables in the Open database.

3.2.3 Viewing column information contained in a table

Show columns from user;

This command looks at the column information in the specified table, including the field name, type, whether it is empty, whether it is a primary key, the default value, and other information, such as the self-increment field.

This command can be replaced with the shortcut describe command, then the above can be rewritten as describe user;

3.2.4 Other show-related commands

Show status, which is used to display server status information.

Show create DATABASE and show create TABLE, respectively, to display the SQL statements that created the databases and created the tables. The database and table names are specified later.

Show grants, which displays permissions granted to a user (all users or a specified user).

Show errors and show warnings, which displays server error or warning messages.

There are a lot of show commands that you want to know, one through help show;

MySQL Quick Start

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.