Mysql most basic command use Rollup _mysql

Source: Internet
Author: User

First, connect MySQL (and PHP with the best combination)

format:- H host address-u user name-P user Password

Example 1: Connect to MySQL on this computer.

First in the Open DOS window, and then into the directory bin, and then type-uroot-p, enter after the prompt you to lose the password, if just installed, Superuser Root is no password, so direct return can enter into MySQL.

Example 2: Connect to MySQL on the remote host.

Assume the IP of the remote host is: 110.110.110.110, username is root, password is abcd123. Type the following command:

Copy Code code as follows:
-h110.110.110.110-uroot-pabcd123

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

3, exit MySQL command: Exit (enter).

Second, modify the password

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

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

Copy Code code as follows:
Admin-uroot-password AB12

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

Example 2: Then change the root password to djg345 and command:

Copy Code code as follows:
ADMIN-UROOT-PAB12 Password djg345

Iii. increasing the number of new users

(Note: Unlike the above, the following are the commands in the MySQL environment, followed by a semicolon as the 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 connect the root user to MySQL, and then type the following command:

  

Copy Code code as follows:
Grant Select,insert,update,

Delete on *.* to test1@\ "%\" identified by \ "Abc\";

But for example 1 the increased user is very dangerous and you want someone who knows Test1 's password so that he can log on to your MySQL database on any computer on the Internet and can do whatever it wants with your data, as shown in Example 2.

Example 2, add a user test2 password for ABC, so that he can only log on the localhost, and can query the database mydb, insert, modify, delete operations (localhost refers to the local host, that is, the MySQL database of the host), This allows a user to use a password that knows test2, and he cannot access the database directly from the Internet, only through a Web page on the MySQL host.

  

Copy Code code as follows:
Grant Select,insert,update,

Delete on mydb.* to test2@localhost identified by \ "Abc\";

If you do not want to test2 the password, you can make another command to eliminate the password.

  

Copy Code code as follows:
Grant Select,insert,update,delete on MyDB

. * to test2@localhost identified by \ "\";

The above describes the login, add users, password changes and other issues, I hope to help you learn.

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.