SoFunction
Updated on 2024-11-15

mysql import export database, data table methods

Linux
All operated under the console.
Import the database:
Prerequisites: Database and data tables should exist (have been created)

(1) Import the data table test_user.sql into the test_user table of the test database.
[root@test ~]# mysql -uroot -p test < /www/web/test/test_user.sql

(2) Import the database into the test database, test.
[root@test ~]# mysql -uroot -p test < /www/web/test/

(3) source command is not under the console, to enter mysql under the operation
mysql> use test;
mysql>source /www/web/test/

Export the database:

(1) Export database test to /www/web/test/.
[root@test ~]# mysqldump -uroot -p test > /www/web/test/
Enter to prompt for a password

(2) Export the user table from the database test to /www/web/test/.
[root@test ~]# mysqldump -uroot -p test user < /www/web/test/