导入MySql文件

展开阅读全文

mysql 导入DMP文件

08-24

C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin>mysql -h localhost -urnot phone < D:\phone.DMP;rnmysql Ver 14.14 Distrib 5.5.15, for Win32 (x86)rnCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights resernrnOracle is a registered trademark of Oracle Corporation and/or itsrnaffiliates. Other names may be trademarks of their respectivernowners.rnrnUsage: mysql [OPTIONS] [database]rn -?, --help Display this help and exit.rn -I, --help Synonym for -?rn --auto-rehash Enable automatic rehashing. One doesn't need to urn 'rehash' to get table and field completion, but srn and reconnecting may take a longer time. Disablern --disable-auto-rehash.rn (Defaults to on; use --skip-auto-rehash to disablrn -A, --no-auto-rehashrn No automatic rehashing. One has to use 'rehash' trn table and field completion. This gives a quickerrn mysql and disables rehashing on reconnect.rn --auto-vertical-outputrn Automatically switch to vertical output mode if trn result is wider than the terminal width.rn -B, --batch Don't use history file. Disable interactive behavrn (Enables --silent.)rn --character-sets-dir=namern Directory for character set files.rn --column-type-info Display column type information.rn -c, --comments Preserve comments. Send comments to the server. Trn default is --skip-comments (discard comments), enrn with --comments.rn -C, --compress Use compression in server/client protocol.rn rn rn rnrnDefault options are read from the following files in the given order:rnC:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf C:\Program FilernySQL\MySQL Server 5.5\my.ini C:\Program Files (x86)\MySQL\MySQL ServerrnfrnThe following groups are read: mysql clientrnThe following options may be given as the first argument:rn--print-defaults Print the program argument list and exit.rn--no-defaults Don't read default options from any option filern--defaults-file=# Only read default options from the given file #rn--defaults-extra-file=# Read this file after the global files are read.rnrnVariables (--variable-name=value)rnand boolean options FALSE|TRUE Value (after reading options)rn--------------------------------- -------------------------------------rnauto-rehash TRUErnauto-vertical-output FALSErncharacter-sets-dir (No default value)rncolumn-type-info FALSErncomments FALSErncompress FALSErndebug-check FALSErndebug-info FALSErndatabase (No default value)rndefault-character-set latin1rndelimiter ;rnvertical FALSErnforce FALSErnnamed-commands FALSErnignore-spaces FALSErninit-command (No default value)rnlocal-infile FALSErnno-beep FALSErnhost localhostrnhtml FALSErnxml FALSErnline-numbers TRUErnunbuffered FALSErncolumn-names TRUErnsigint-ignore FALSErnport 3306rnprompt mysql>rnrnrnC:\Program Files (x86)\MySQL\MySQL Server 5.5\bin>rnrn这是成功还是没成功? 论坛

EXCEL文件导入MYSQL出错

11-14

在的表格很简单,就12列数据,要导入MYSQLrn在网上找的代码,自己测试的文件和下载的文件都在一个文件夹里,rn有四个文件1,data.xls 2.index.php 3,reader.php(下载的) 4,oleread.inc(下载的) rnrndata.xls表格里数据rnnum,names,years,season,groups,colornote,colornum,price,types,sizes,materials,notern有两行记录rnrnindex代码如下rn[code=php]setOutputEncoding('gbk'); rn//”data.xls”是指要导入到mysql中的excel文件 rn$data->read('data.xls'); rn@ $db = mysql_connect('localhost', 'root', '123123') or rndie("Could not connect to database.");//连接数据库 rnmysql_query("set names 'gbk'");//输出中文 rnmysql_select_db('test'); //选择数据库 rnerror_reporting(E_ALL ^ E_NOTICE); rnfor ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) rn//以下注释的for循环打印excel表数据 rn/* rnfor ($j = 1; $j < = $data->sheets[0]['numCols']; $j++) rnecho "\"".$data->sheets[0]['cells'][$i][$j]."\","; rn rnecho "\n"; rn*/ rn//以下代码是将excel表数据【3个字段】插入到mysql中, rn//根据你的excel表字段的多少,改写以下代码吧! rn$sql = "INSERT INTO test rn(rn num,names,years,season,groups,colornote,colornum,price,types,sizes,materials,notern)rnVALUES('". rn$data->sheets[0]['cells'][$i][1]."','". rn$data->sheets[0]['cells'][$i][2]."','". rn$data->sheets[0]['cells'][$i][4]."','". rn$data->sheets[0]['cells'][$i][5]."','". rn$data->sheets[0]['cells'][$i][6]."','". rn$data->sheets[0]['cells'][$i][7]."','". rn$data->sheets[0]['cells'][$i][8]."','". rn$data->sheets[0]['cells'][$i][9]."','". rn$data->sheets[0]['cells'][$i][10]."','". rn$data->sheets[0]['cells'][$i][11]."','". rn$data->sheets[0]['cells'][$i][12]."')"; rnecho $sql.'< br />'; rn$res = mysql_query($sql); rn rn?>[/code] rnrn运行index.php报以下错误rnrnFatal error: Call to a member function read() on a non-object in D:\AppServ\www\aaee\index.php on line 4 论坛

没有更多推荐了,返回首页