in fact, MySQL's operation of the database and other SQL class database is similar, you'd better find a book to read the SQL. I only introduce some basic, in fact, I only understand these, hehe.
One, the connection MySQL.
Format: mysql-h host address-u user name-P user Password
1, Example 1: Connect to MySQL on this machine.
First in the Open DOS window, and then into the directory Mysqlbin, and then type the command mysql-uroot-p, enter after the prompt you to lose the password, if just installed MySQL, superuser root is no password, so direct return can enter into MySQL, The MySQL prompt is: mysql>
2, Example 2: Connect to the remote host MySQL. Assume the IP of the remote host is: 110.110.110.110, username is root, password is abcd123. Type the following command:
Mysql-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: Mysqladmin-u username-P Old password password new password
1, Example 1: To root add a password ab12. First enter the directory Mysqlbin in DOS, and then type the following command
Mysqladmin-uroot-password AB12
Note: Since Root does not have a password at the beginning, the-p old password can be omitted.
2, Example 2: Then the root password changed to djg345.
MYSQLADMIN-UROOT-PAB12 Password djg345
Third, add 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:
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 the 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.
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.
Grant Select,insert,update,delete on mydb.* to Test2@localhost identified by "";
Let's look at MySQL about database operations. Note: You must first log in to MySQL, and the following actions are performed under the MySQL prompt, and each command ends with a semicolon.
First, the Operation skill
1, if you hit the command, when you find that you forgot to add a semicolon, you do not need to repeat the command, as long as a semicolon to enter on it. That is to say, you can divide a complete command into lines, and then use a semicolon as the closing sign to make it OK.
2, you can use the cursor up and down keys to pull up the previous command. But I used to use a MySQL older version does not support. I'm using a mysql-3.23.27-beta-win.
Total 2 page: previous 1 [2] Next page