MySQL command memo shares the majority of applications in practice. If you are curious about this technology, this article will unveil its mystery. The following is a description of the specific solution. I hope it will help you in your future study. I. MySQL command memo: connect to MySQL. Format: MySQL-h host address-u user name-p User Password
MySQL command memo shares the majority of applications in practice. If you are curious about this technology, this article will unveil its mystery. The following is a description of the specific solution. I hope it will help you in your future study. I. MySQL command memo: connect to MySQL. Format: MySQL-h host address-u user name-p User Password
MySQL command memo shares the majority of applications in practice. If you are curious about this technology, this article will unveil its mystery. The following is a description of the specific solution. I hope it will help you in your future study.
I. MySQL command memo: connect to MySQL.
Format: MySQL-h host address-u user name-p User Password
1. Example 1: connect to MySQL on the local machine.
First, open the DOS window, enter the directory MySQLbin, then type the command MySQL-uroot-p, and press enter to prompt you to enter the password. If you have just installed MySQL, super User root has no password, so press enter to enter MySQL. The MySQL prompt is: MySQL>
2. Example 2: connect to MySQL on the remote host. Assume that the IP address of the remote host is 110.110.110.110, the user name is root, and the password is abcd123. Enter the following command:
MySQL-h110.110.110.110-uroot-pabcd123
(Note: you do not need to add spaces for u and root. The same applies to others)
3. exit MySQL command: exit (Press ENTER)
2. Change the password.
Format: MySQLadmin-u username-p old password New password
1. Example 1: Add a password ab12 to the root user. First, enter the directory MySQLbin in DOS, and then type the following command
MySQLadmin-uroot-password ab12
Note: because the root account does not have a password at the beginning, the old-p password can be omitted.
2. Example 2: Change the root password to djg345.
MySQLadmin-uroot-pab12 password djg345
Iii. MySQL command memo: Add new users.
(Note: Unlike the above, the following commands in the MySQL environment 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 named "test1" with the password "abc" so that the user can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MySQL, and then type the following command:
Grant select, insert, update, delete on *. * to test1 @ \ "% \" Identified by \ "abc \";
However, the User Added in Example 1 is very dangerous. If someone knows the password of test1, then he can log on to your MySQL database on any computer on the internet and do whatever he wants for your data. For the solution, see Example 2.
Example 2: Add a user named "test2" with the password "abc" so that the user can only log on to localhost, you can also query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MySQL database is located), so that the user knows the password of test2, he cannot access the database directly from the internet, but can only access the database through the web pages on the MySQL host.
Grant select, insert, update, delete on mydb. * to test2 @ localhost identified by \ "abc \";
If you do not want test2 to have a password, you can run another command to remove the password.
Grant select, insert, update, delete on mydb. * to test2 @ localhost identified \"\";
In the previous article, we talked about logon, adding users, and changing passwords. Next, let's take a look at the database operations in MySQL. Note: you must first log on to MySQL. The following operations are performed at the MySQL prompt and each command ends with a semicolon.
I. Operation Skills
1. If you forget the extra points after you press Enter when making the command, you don't have to repeat the command. You just need to press a semicolon to press Enter. That is to say, you can divide a complete command into several lines, and then use a semicolon as the end sign to complete the operation.
2. You can use the cursor to bring up or down the previous commands. However, an old MySQL version I used earlier does not support this feature. I am using a MySQL-3.23.27-beta-win.
Ii. Display commands
1. display the Database List.
Show databases;
At the beginning, there were only two databases: MySQL and test. The MySQL database contains the MySQL system information. We change the password and add new users to use this database for operations.
2. display the data tables in the database:
Use MySQL; // open the database. If you have learned FOXBASE, you will not be unfamiliar with it.
Show tables;
3. display the data table structure:
Describe table name;
4. database creation:
Create database name;
5. Create a table:
Use Database Name;
Create table Name (field setting list );
6. Delete databases and tables:
Drop database name;
Drop table name;
7. Clear records in the table:
Delete from table name;
8. Display records in the table:
Select * from table name;
The above content is an introduction to the MySQL command memo. I hope you will get something better.