MySQL connection and basic information view command Summary

Source: Internet
Author: User

MySQL connection and basic information view command Summary
Preface

I had to mention MySQL when learning PHP. Although phpMyadmin and other tools can operate databases graphically, I still want to use the following command line to operate databases by learning PHP. The following is my learning summary, including the command line connecting to the database, viewing the current user, viewing the currently used storage engine, viewing the MySQL version and other basic commands.

Connect to database

Command Format: mysql-h hostname-u username-p
-H specifies the host of the MySQL database to be connected. If it is a local machine, it can be omitted.
-U indicates the user name to log on to. If this parameter is not specified, the default user name is the operating system logon user name.
-P specifies the password. You can enter the password directly after-p, but the password will be displayed in this way. A good way is to do not enter the password first. After you press enter, the system will prompt you to enter the password, and then enter the password to use. This is relatively safer. After correct connection, the welcome page will appear. As shown in:

Exit the database and use the quit command.
When an application connects to the database, it is recommended that you do not use the root administrator user to connect. A good way is to create one or more common users with specific permissions for the application to operate the database. Ordinary users follow the minimum permission principle, which can maximize the security of the database.

View various database information view commands view the database version select version (); view the storage engines supported by the database and the current default storage engine show engines;
Shows all the storage engines of the MySQL database. default is the current default storage engine, and whether transactions are supported. view the user Name of the currently logged-on database, select user (); view the permissions of the currently logged-on Database User show grants for sally;-sally shows all databases that the current user can see for the user name; go to the specified database use books; -view show tables for all tables in the current database for the database name, describe MERs for the structure information of a table, and-customers for the table name
Shows the command running status:

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.