Teach you to use mysql:mysql common commands at a Glance _php tutorial

Source: Internet
Author: User
Tags mysql commands
There are a lot of friends, although installed MySQLBut I don't know how to use it. In this article, we will learn some common MySQL commands from connecting MySQL, changing passwords, and adding users.

First, connect MySQL.

Format: mysql-h host address-u user name-P user Password

1. Example 1: Connect to MySQL on this machine.

First, open the DOS window, then go to directory Mysqlbin, and then type the command mysql-uroot
-P, enter after the prompt you lose password, if just installed MySQL, superuser root is no password, so directly enter into MySQL, MySQL prompt is:mysql>

2. Example 2: Connect to MySQL on the remote host. Assume the remote host IP is: 110.110.110.110, the user name is root, the password is abcd123. Type the following command:

Mysql-h110.110.110.110-uroot-pabcd123

(Note: You and root can be used without spaces, others are the same)

3. Exit MySQL command: Exit (enter)

Second, change the password.

Format: Mysqladmin-u username-P Old password password new password

1, Example 1: Add a password to root ab12. First enter directory Mysqlbin under DOS, and then type the following command

Mysqladmin-uroot-password AB12

Note: Because Root does not have a password at the beginning, the-p old password can be omitted.

2, Example 2: Then change the root password to djg345.

MYSQLADMIN-UROOT-PAB12 Password djg345

Third, add new users. (Note: Unlike the above, the following is because it is a command in a MySQL environment, so it is followed by a semicolon as a command terminator)

Format: Grant Select on database. * To User name @ login host identified by
Password

Example 1, add a user test1 password for ABC, so that he can log on any host, and all databases have query, insert, modify, delete permissions. First, use the root user to connect to MySQL, and then type the following command:

Grant Select,insert,update,delete on *.

http://www.bkjia.com/PHPjc/631016.html www.bkjia.com true http://www.bkjia.com/PHPjc/631016.html techarticle There are a lot of friends who have installed MySQL but don't know how to use it. In this article we will connect MySQL, change passwords, add users and so on to learn some of the common life of MySQL ...

  • 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.