MySQL connection and basic information view command summary, basic mysql Information

Source: Internet
Author: User

MySQL connection and basic information view command summary, basic mysql Information

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.

Various database information viewing 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 is the user name
  • View All databases that the current user can see;
  • Go to the specified database use books;-books is the database name
  • View all tables in the current database;
  • View the structure information of a table: describe MERs MERS;-customers indicates the table name.

Shows the command running status:

The above is the summary of the MySQL connection and basic information viewing command, I hope you will like it.

Articles you may be interested in:
  • View mysql threads using the processlist command
  • How to install and set remote connection for Linux mysql commands
  • Mysql Command Prompt line connection garbled Solution
  • How to use SQL commands to view the Mysql database size
  • Php cannot connect to mysql, but mysql command line operations are normal solution
  • Start, stop, and restart MySQL In Ubuntu. view the error log command list.
  • Use mysqladmin extended-status in Linux with Linux commands to view the MySQL running status
  • Summary of Common commands for viewing and clearing tables in MySQL
  • Command for MySQL to start the connection and basic syntax for connecting to the PHP Program

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.