mysql备份数据库以及拷贝数据库到另一台服务器上
可以用mysqladmin 创建db,不需要进入后再去创建了。 将mysql数据库导入目标机器后,执行 mysqladminflush-privileges ,以便服务器重载授权表信息。 D:\MySql 5.1.73\bin\mysqladmin -u root create test2; D:\Mysql 5.1.73\bin\mysqladmin -u root drop te
可以用mysqladmin 创建db,不需要进入后再去创建了。
将mysql数据库导入目标机器后,执行mysqladmin flush-privileges,以便服务器重载授权表信息。
D:\MySql 5.1.73\bin\mysqladmin -u root create test2;
D:\Mysql 5.1.73\bin\mysqladmin -u root drop test2;
warning:
Dropping the database is potentially a very hard thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the 'test2' database [y/n]
----------------------------------------------------------------------------
你可以在支持相同浮点格式的不同架构之间为MyISAM表复制.frm、.MYI和.MYD文件。(MySQL关注所有字节交换问题)。请参见15.1节,“MyISAM存储引擎”。
如果你需要在不同的架构之间转移数据库,可以使用mysqldump创建含有SQL语句的文件。然后你可以将文件转移到其它机器上,并将它输入到MySQL客户端。
使用mysqldump --help来看有哪些选项可用。如果你正将数据移动到更新版本的MySQL,你应当使用mysqldump –opt来利用各种优化性能来产生更小、可以更快处理的转储文件。
在两台机器之间移动数据库的最简单(尽管不是最快)的方法是在数据库所在的机器上运行下面的命令:
shell> <strong>mysqladmin -h '<em>other_hostname</em>' create <em>db_name</em></strong>
shell> <strong>mysqldump --opt <em>db_name</em> | mysql -h '<em>other_hostname</em>' <em>db_name</em></strong>
如果你想要从远程机器通过慢速网络复制数据库,可以使用:
shell> <strong>mysqladmin create <em>db_name</em></strong>
shell> <strong>mysqldump -h '<em>other_hostname</em>' --opt --compress <em>db_name</em> | mysql <em>db_name</em></strong>
还可以将结果保存到文件中,然后将文件转移到目标机器上并将文件装载到数据库中。例如,可以在源机器上使用下面的命令将数据库备份到文件中:
shell> <strong>mysqldump --quick <em>db_name</em> | gzip > <em>db_name.contents</em>.gz</strong>
(该例子中创建的文件是压缩格式)。将含有数据库内容的文件到目标机上并运行命令:
shell> <strong>mysqladmin create <em>db_name</em></strong>
shell> <strong>gunzip db_name.contents.gz | mysql <em>db_name</em></strong>
还可以使用mysqldump和mysqlimport来转移数据库。对于大的表,比只是使用mysqldump要快得多。在下面的命令中,DUMPDIR代表用来保存mysqldump输出的目录全路径名。
首先,创建保存输出文件的目录并备份数据库:
shell> <strong>mkdir DUMPDIR</strong>
shell><strong>mysqldump --tab=DUMPDIR <em>db_name</em></strong>
然后将DUMPDIR目录中的文件转移到目标机上相应的目录中并将文件装载到MySQL:
shell> <strong>mysqladmin create <em>db_name</em> # create database</strong>
shell> <strong>cat DUMPDIR/*.sql | mysql <em>db_name</em> # create tables in database</strong>
shell> <strong>mysqlimport <em>db_name</em> DUMPDIR/*.txt # load data into tables</strong>
不要忘记复制MySQL数据库,因为授权表保存在该数据库中。你可能需要在新机器上用MySQL root用户运行命令,直到产生MySQL数据库。
将mysql数据库导入目标机器后,执行mysqladmin flush-privileges,以便服务器重载授权表信息。
----------------------------------------------------------------------------------------------------------------------------------
按照上面的方法试了个多小时成功了,主要是上面的命令说的不是很完整:
shell> <strong>mysqladmin -h '<em>other_hostname</em>' create <em>db_name</em></strong>
<strong><em>(mysqladmin -h other_hostname -u username -p create db_name)</em></strong>
shell> <strong>mysqldump --opt <em>db_name</em> | mysql -h '<em>other_hostname</em>' <em>db_name</em></strong>
<strong><em>(</em><strong>mysqldump -h local_host -u username -p local_<em>db_name</em> | mysql -h <em>other_hostname -u username -p db_name</em></strong><em>)</em></strong>

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



In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

Navicat itself does not store the database password, and can only retrieve the encrypted password. Solution: 1. Check the password manager; 2. Check Navicat's "Remember Password" function; 3. Reset the database password; 4. Contact the database administrator.

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

Copying a table in MySQL requires creating new tables, inserting data, setting foreign keys, copying indexes, triggers, stored procedures, and functions. The specific steps include: creating a new table with the same structure. Insert data from the original table into a new table. Set the same foreign key constraint (if the original table has one). Create the same index. Create the same trigger (if the original table has one). Create the same stored procedure or function (if the original table is used).

Navicat for MariaDB cannot view the database password directly because the password is stored in encrypted form. To ensure the database security, there are three ways to reset your password: reset your password through Navicat and set a complex password. View the configuration file (not recommended, high risk). Use system command line tools (not recommended, you need to be proficient in command line tools).

View the MySQL database with the following command: Connect to the server: mysql -u Username -p Password Run SHOW DATABASES; Command to get all existing databases Select database: USE database name; View table: SHOW TABLES; View table structure: DESCRIBE table name; View data: SELECT * FROM table name;

Copy and paste in MySQL includes the following steps: select the data, copy with Ctrl C (Windows) or Cmd C (Mac); right-click at the target location, select Paste or use Ctrl V (Windows) or Cmd V (Mac); the copied data is inserted into the target location, or replace existing data (depending on whether the data already exists at the target location).
