Mysql Connection and basic Information view command Rollup _mysql

Source: Internet
Author: User

Learn PHP will have to mention MySQL, although there are phpmyadmin such tools can be graphical operation of the database, but I still want to learn PHP to use the command line to manipulate the database. Here's a summary of my studies, including command line connection databases, viewing current users, viewing current storage engines, and viewing MySQL versions of BASIC commands.

Connecting to a database

Command format:mysql-h hostname-u username-p
-h Specifies the host of the MySQL database to which you want to connect, and if this is the local computer, you can omit it.
-u Specifies the user name of the login, or, if not specified, the operating system's login username by default.
-p Specifies a password. You can enter the password directly after-p, but this way the password will be displayed. A good way is not to enter the password, enter the system will prompt for a password, and then enter the password will be used * display. This is relatively safe. The welcome interface appears when the connection is correct. As shown in the following illustration:

Exit the database using the QUIT command.
When an application connects to a database, it is recommended that you do not use the root administrator user connection. A good approach is to manipulate the database for ordinary users who create one or several specific permissions for the application. For ordinary users to follow the principle of least privilege, this can maximize the security of the database.

Various database Information view commands

    • View the version of the database Select Edition ();
    • View the storage engine supported by the database and the current default storage engine show engines;

As shown in the following illustration, all the storage engines for the MySQL database are displayed, default is the current defaults storage engine, and whether to support transactions such as: Write a picture description here

    • View the user name of the currently logged-on database, select User ();
    • View permissions for the currently logged-on database user show grants for Sally; –sally for User name
    • View all databases that the current user can see show databases;
    • Go to the specified database use books; –books for Database name
    • View all tables in the current database show table;
    • View the structure information of a table describe customers; –customers for Table name

The above command runs as shown in the following illustration:

The above is the summary of MySQL connection and basic Information view command, I hope you like.

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.