When a path is not received, the path to the lookup file is the path to the MySQL command when it is executed
Paths, use the path +filename
[[email protected] MySQL]#VI demo.mysql[[email protected] MySQL]#pwd/root/Mysql[root@wordpressserver MySQL]#Ls-alTotal 12drwxr-xr-x. 2 root root 4096 Nov 2 21:45. Dr-xr-x---. Root root 4096 Nov 2 21:49 ..-rw-r--r--. 1 root root for 2 21:45Demo.mysql[root@wordpressserver MySQL]# MySQL>source demo.mysqlERROR:Failed to open file ' Demo.mysql ', error:2MySQL> source/root/mysql/demo.mysqldatabase changedquery OK,0 rows affected (0.01sec) MySQL>show tables;+----------------+| Tables_in_demo |+----------------+| Example |+----------------+1 rowinchSet (0.00 sec)
- Mysqldump Export a table using the SQL File recovery table
[[Email protected] ~]#mysqldump-u root-p demodabasename exampletablename > Sqldumptest1.sqlEnter Password: [Root@wordpressserver ~]#lsAnaconda-ks.cfg Desktop Downloads mysql post-install public Templates vmtool Wordpre SS wordpress-4.4.2-Zh_CN.tar.gzcore.3990 Documents Music Pictures post-install.log sqldumptest1.sql Videos vmware-install.pl WordPress (2) [Root@wordpressserver ~]#VI sqldumptest1.sql[[Email protected] ~]#mysql-uroot-f Demo < Sqldumptest1.sqlERROR 1045 (28000): Access denied forUser ' root ' @' localhost ' (using password:no) [Root@wordpressserver ~]#mysql-uroot-p123456-f Demo < Sqldumptest1.sql[[Email protected] ~]#
Or
[[Email protected] ~] # mysql-uroot-p123456-f Demo </root/mysql/demo.mysql
-F is to ignore the error and continue execution
MySQL> show tables; +----------------+| Tables_in_demo |+----------------+| Example in Set (0.00 sec) MySQL> desc example; +-------+--------------+------+-----+---------+-------+| Field | Type Default | Extra |+-------+--------------+------+-----+---------+-------+| ID | int | YES | | NULL | | | data | varchar (100) | YES | | NULL | in Set (0.00 sec)
Shell> mysqladmin Create Target_db_name
shell> MySQL Target_db_name < backup-file.sql
It is
shell> MySQL Library name < file name
Or
B: Using the mysqldump command
Mysqldump-u Username-p dbname < Filename.sql
C: Using the MySQL command
Mysql-u Username-p-D dbname < Filename.sql
"MYSQL" Common Command Memo