"MYSQL" Common Command Memo

Source: Internet
Author: User

    • Source

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.