Steps:
1. MySQL Command Line Mode settings:
Desktop> my computer> Properties> environment variables> New> Path = "; Path/MySQL/bin;" path indicates the installation path of MySQL.
2. How to access MySQL through the command line:
1. c: \> mysql-H hostname-u username-P
Press enter, and then enter the password. Here, hostname is the name of the server, for example, localhost and username is the MySQL user name, for example, root. You can directly operate MySQL by entering the command line.
3. Export Database files from the database:
1. Export the database mydb to the E: \ mysql \ mydb. SQL file:
Open start> RUN> Enter cmd to enter Command Line Mode
C: \> mysqldump-H localhost-u root-P mydb> E: \ mysql \ mydb. SQL
Enter the password and wait for a moment until the export is successful. You can check whether the export is successful in the target file.
2. Export mytable in mydb to the E: \ mysql \ mytable. SQL file:
C: \> mysqldump-H localhost-u root-P mydb mytable> E: \ mysql \ mytable. SQL
3. Export the database mydb structure to the E: \ mysql \ mydb_stru. SQL file:
C: \> mysqldump-H localhost-u root-P mydb -- add-drop-Table> E: \ mysql \ mydb_stru. SQL
//-H localhost can be omitted, which is generally used on a VM.
4. import data from external files to the database:
Import the SQL statements in the file into the database from E: \ mysql \ mydb2. SQL:
C: \> mysql-H localhost-u root-P mydb2 <E: \ mysql \ mydb2. SQL
Then enter the password, and then OK.
5. Solution to the import file size limit:
By default, MySQL imposes a limit on the size of the imported files. The maximum size is 2 MB. Therefore, when the file is large, it cannot be imported directly:
1. Modify related parameters in PHP. ini:
There are three parameters that affect the size of the MySQL import file:
Memory_limit = 128 M, upload_max_filesize = 2 m, post_max_size = 8 m
Modify upload_max_filesize = 250 m. Modify the size that meets your needs. Modify the other two items memory_limit = m and post_max_size = m at the same time. Then you can import the. SQL file below M.
In the above example, you can place MySQL in the system path. For example, my MySQL installation directory is D: \ MySQL Server 5.0;
First open the DOS window, then enter D :( no '\') and press ENTER
In this case, the D: \> flag should appear, and enter D: \ MySQL Server 5.0 \ bin and press Enter.
D: \ MySQL Server 5.0 \ bin> appears. Enter mysqldump-u root-P Database Name> database name. SQL (you can also enter the path). (refer to the above for details)
The file to be imported is the same. You only need to change '>' to '<', or you can directly use source:
Common source commands
Go to the MySQL Database Console, for example, MySQL-u root-P.
Mysql> Use Database
Then run the source command. The following parameter is the script file (. SQL is used here)
Mysql> source D: \ mydb. SQL