# 使用xunsearch导出索引报错Not contain dbname of DB connection parameter

**URL:** <https://www.shiqidu.com/t/topic/315>\
**Category:** 开发调优\
**Tags:** PHP\
**Created:** [2017 年11 月 26 日 11:36 UTC](https://www.shiqidu.com/t/topic/315 "2017-11-26T11:36:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2017 年11 月 26 日 11:36 UTC](https://www.shiqidu.com/t/topic/315/1 "2017-11-26T11:36:01Z")

</div>

本想搞个国产搜索引擎代替coreseek，搜到了xunsearch，网上评价不错，就安装了试试。

结果在导入索引的时候一直失败，报了下面的错。

```bash
[XSException] /XSDataSource.class.php(163): Not contain dbname of DB connection parameter  
#0 XSDataSource.class.php(35): XSDatabaseDataSource-&gt;init()  
#1 XSDataSource.class.php(51): XSDataSource-&gt;__construct('mysql://root:6C...', 'select * from s...')  
#2 Indexer.php(244): XSDataSource::instance('mysql://root:6C...', 'select * from s...')  
#3 {main}  

```

看了下这个报错的这个文件，在上边找到了这样的一行代码。

![e8068223a9f30064c281c89c3de334ba.png](https://discourse.shiqidu.com/uploads_nj/article/20171126/e8068223a9f30064c281c89c3de334ba.png)

使用了`parse_url`去解析参数，如果你的密码中有\*\*#\*\*就报错了,因为`parse_url`函数会把`#`后的解析到`fragment`中去。导致密码被截断，整个命令行的参数也都错了，自然也找不到`dnname`数据库名这个参数了。

原因知道了，怎么解决呢？

不改源代码的话好像只能把数据库密码中的`#`去掉了。
