mysqldump:数据库备份程序
mysqldump:数据库备份程序 有 3 种方式来调用 mysqldump : mysqldump [ options ] db_name [ tables ] mysqldump [ options ] -- -database DB1 [DB2 DB3...] mysqldump [ options ] -- all--database 如果没有指定任何表或使用了 ---database 或 --all--d
mysqldump:数据库备份程序
有3种方式来调用mysqldump:
mysqldump <span>[</span><span>options</span><span>]</span> <span>db_name</span> <span>[</span><span>tables</span><span>]</span><span> mysqldump </span><span>[</span><span>options</span><span>]</span> <span>--</span><span>-database DB1 [DB2 DB3...]</span> mysqldump <span>[</span><span>options</span><span>]</span> <span>--</span><span>all--database</span>
如果没有指定任何表或使用了---database或--all--database选项,则转储整个数据库。
备份一个数据库.
mysqldump <span>-</span>uroot <span>-</span>p123456 mysql <span>></span> mysql_backup.sql
这里备份了database mysql的结构和数据,生成的sql文件不会有创建database mysql的语句。
可以用一个命令备份mysql,test多个数据库:
mysqldump <span>-</span>u root <span>-</span>p123456 <span>--</span><span>database mysql test > my_databases.sql</span>
生成的sql文件有创建database mysql和test的语句
备份所有数据库:
mysqldump <span>-</span>u root <span>-</span>p123456 <span>--</span><span>all-databases > all_databases.sql</span>
导出mysql这个数据库的结构
mysqldump <span>-</span>u root <span>-</span>p123456 <span>-</span>d <span>--</span><span>add-drop-table mysql > mysql_define.sql</span>
导出一个数据所有数据并用gz压缩
mysqldump <span>-</span>u root <span>-</span>p123456 mysql <span>|</span> gzip <span>></span> mysql.sql.gz
可以这样将转储文件读回到服务器:
mysql <span>db_name</span> <span> <span>backup</span><span>-</span><span>file</span><span>.sql mysql </span><span>-</span>e "source <span>/</span>path<span>-</span><span>to</span><span>--</span><span>backup/backup-file.sql" db_name</span></span>
或者从gz文件中还原
gunzip <span>-</span>f <span> mysql.sql.gz <span>|</span> mysql <span>-</span>u root <span>-</span>p123456 test</span>
更多参考 http://dev.mysql.com/doc/refman/5.1/zh/client-side-scripts.html#mysqldump
SELECT...INTO OUTFILE
SELECT...INTO OUTFILE 'file_name'形式的SELECT可以把被选择的行写入一个文件中,该文件被创建到服务器主机上。
SELECT...INTO OUTFILE是LOAD DATA INFILE的补语;用于语句的exort_options部分的语法包括部分FIELDS和LINES子句,这些子句与LOAD DATA INFILE语句同时使用。
在下面的例子中,生成一个文件,各值用逗号隔开。这种格式可以被许多程序使用
<span>SELECT</span> <span>*</span> <span>INTO</span> OUTFILE <span>'</span><span>/tmp/result.txt</span><span>'</span><span> FIELDS TERMINATED </span><span>BY</span> <span>'</span><span>,</span><span>'</span><span> OPTIONALLY ENCLOSED </span><span>BY</span> <span>'</span><span>"</span><span>'</span><span> LINES TERMINATED </span><span>BY</span> <span>'</span><span>\n</span><span>'</span> <span>FROM</span> mysql.<span>user</span>;
将mysql数据库的user表的数据导出到/tmp/result.txt
SELECT...INTO OUTFILE只能导出数据,不能导出结构,一般和load data联合使用。
更多参考 http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#select
LOAD DATA INFILE
LOAD DATA INFILE语句用于高速地从一个文本文件中读取行,并装入一个表中。文件名称必须为一个文字字符串。
由character_set_database系统变量指示的字符集被用于解释文件中的信息。
<span>LOAD</span> DATA LOCAL INFILE <span>'</span><span>/tmp/result.txt' INTO TABLE test.user FIELDS TERMINATED BY </span><span>'</span>,<span>'</span><span> OPTIONALLY ENCLOSED BY </span><span>'</span>"<span>'</span><span> LINES TERMINATED BY </span><span>'</span>\n<span>'</span>
把/tmp/result.txt的数据导入到test数据库的user表。
更多参考 http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#load-data

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.
