Export and Import mysql Data in linux
Export all data in the entire database
1. Enter the following in the linux Command Line:
mysqldump -u userName -p dabaseName > fileName.sql
FileName. It is best to add the path name to SQL.
Export the data of a table in the database
mysqldump -u userName -p dabaseName tableName > fileName.sql
Export all table structures in the entire database
In the linux Command Line, enter:
mysqldump -u userName -p -d dabaseName > fileName.sql
Note:-d is added.
Export the table structure of a table in the entire database
In the linux Command Line, enter:
mysqldump -u userName -p -d dabaseName tableName > fileName.sql
Note:-d is added.
Import mysql method 1
Go to the linux Command Line:
Mysql-uroot-p press enter and enter the password source fileName. SQL. Note that fileName. SQL requires a path name, for example, source/home/user/data/fileName. SQL.
Method 2 for importing mysql
Go to the linux Command Line:
Mysql-uroot-p database <fileName. SQL note that fileName. SQL must have a path name
How to import and export MySQL Databases in linux
1. Export: Use mysqldump command line Command Format mysqldump-u username-p Database Name> database name. SQL example: mysqldump-u root-p abc> abc. SQL (Export Database abc to abc. SQL file) when you are prompted to enter a password, enter the password of the database user name. Ii. Import: Use the mysql command line Command Format mysql-u user name-p database name III. If the database is large, you can use the direct COPY method, however, different versions and operating systems may be incompatible with each other, so use them with caution. 3.1 package the original database with tar as a file tar-zcvf mydb.tar.gz mydb3.2 to create an empty database. 3.3 unzip the database to a temporary directory, for example: cd/tmptar-zxvf mydb.tar.gz 3.4 copy the extracted database file to the related directory cd mydb/cp */var/lib/mysql/mydb/For FreeBSD: cp */var/db/mysql/mydb/3.5 permission setting: Change the owner of the copied files to mysql: mysql, and change the permission to 660 chown mysql: mysql/var/lib/mysql/mydb /*
In linux, how does one Import and Export MySQL databases ??
How to import and export MySQL Databases in linux 1. 2. 3. 1. Export: 4. use the mysqldump command line 5. command Format 6. mysqldump-u username-p Database Name> database name. SQL 7. example: 8. mysqldump-u root-p abc> abc. SQL 9. (export the database abc to abc. SQL file) 10. 11. enter the password of the Database User Name When prompted. 12. 13. ii. Import: 14. use mysql Command Line 15. command Format 16. mysql-u username-p database name <database name. SQL 17. example: 18. mysql-u root-p abc <abc. SQL 19. (import database abc from abc. SQL file) 20. 21. enter the password of the Database User Name When prompted. 25.3.1 pack the original database with tar as a file 26.tar-zcvf mydb.tar.gz mydb 27.3.2 and create an empty database 28. 29.3.3 extract 30. decompress the package in the temporary directory, for example, 31.cd/tmp 32.tar-zxvf mydb.tar.gz 33. 34.3.4 copy 35. copy the extracted database file to the related directory 36.cd mydb/37.cp */var/lib/mysql/mydb/38. 39. for FreeBSD: 40.cp */var/db/mysql/mydb/41. 42.3.5 permission settings 43. change the owner of the copied files to mysql: mysql and the permission to 660 44. chown mysql: mysql/var/lib/mysql/mydb/* 45. chmod 660/var/lib/mysql/mydb /*