Teach you how to use MySQL: List of common MySQL commands_PHP tutorial

WBOY
Release: 2016-07-13 17:02:47
Original
807 people have browsed it

There are many friends who have installed mysql but don’t know how to use it. In this article, we will learn some common MYSQL commands from connecting to MYSQL, changing passwords, adding users, etc.

1. Connect to MYSQL.

Format: mysql -h host address -u username -p user password

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

First open the DOS window, then enter the directory mysqlbin, and then type the command mysql -uroot
-p. After pressing Enter, you will be prompted to enter your password. If MYSQL has just been installed, the super user root does not have a password. , so just press Enter to enter MYSQL. The prompt for MYSQL is: mysql>

2. Example 2: Connect to MYSQL on the remote host. Assume that the IP of the remote host is: 110.110.110.110, the user name is root, and the password is abcd123. Then type the following command:

mysql -h110.110.110.110 -uroot -pabcd123

(Note: u and root do not need spaces, and the same goes for others)

3 . Exit the MYSQL command: exit (Enter)

2. Change the password.

Format: mysqladmin -u username -p old password password new password

1. Example 1: Add a password ab12 to root. First enter the 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 item can be omitted. .

2. Example 2: Change the root password to djg345.

mysqladmin -uroot -pab12 password djg345

3. Add new users. (Note: Unlike the above, the following are commands in the MYSQL environment, so they are followed by a semicolon as the command terminator)

Format: grant select on database.* to username@login host identified by
"Password"

Example 1. Add a user test1 with the password abc, so that he can log in on any host and have query, insert, modify, and delete permissions on all databases. First connect to MYSQL as the root user, and then type the following command:

grant select,insert,update,delete on *.* to

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631016.htmlTechArticleThere are many friends who have installed mysql but don’t know how to use it. In this article, we will learn some common MYSQL commands from connecting to MYSQL, changing passwords, adding users, etc...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!