可以用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>

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。


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

Atom editor mac version download
The most popular open source editor

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.