Re: how to escape special charactors in connection strings

62 views
Skip to first unread message

RjOllos

unread,
May 8, 2013, 6:11:54 PM5/8/13
to trac-...@googlegroups.com
On Wednesday, May 8, 2013 1:35:02 AM UTC-7, xiangjun zhang wrote:
I just type command:
trac-admin /path/to/project initenv
and when it comes to the connect strings, my database password is something like this:
mysql://root:*@*@localhost:3306/project

escaping or quoting does not work, any help?

What error do you encounter? Could you post the traceback?

I don't think it's necessary to do any escaping on the connection string. See:

xiangjun

unread,
May 13, 2013, 3:02:50 AM5/13/13
to trac-...@googlegroups.com
[root@vps web]# trac-admin /web/xserver initenv
Creating a new Trac environment at /web/xserver

Trac will first ask a few questions about your environment 
in order to initialize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> xserver
 
 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an already existing
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]> mysql://root:foo@bar@localhost:3306/xserver

Creating and Initializing Project
Initenv for '/web/xserver' failed. 
Failed to create environment.
(2005, "Unknown MySQL server host 'bar@localhost' (2)")
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/trac/admin/console.py", line 455, in do_initenv
    options=options)
  File "/usr/lib/python2.6/site-packages/trac/core.py", line 124, in __call__
    self.__init__(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/trac/env.py", line 281, in __init__
    self.create(options)
  File "/usr/lib/python2.6/site-packages/trac/env.py", line 572, in create
    DatabaseManager(self).init_db()
  File "/usr/lib/python2.6/site-packages/trac/db/api.py", line 239, in init_db
    connector.init_db(**args)
  File "/usr/lib/python2.6/site-packages/trac/db/mysql_backend.py", line 111, in init_db
    params)
  File "/usr/lib/python2.6/site-packages/trac/db/mysql_backend.py", line 92, in get_connection
    cnx = MySQLConnection(path, log, user, password, host, port, params)
  File "/usr/lib/python2.6/site-packages/trac/db/mysql_backend.py", line 263, in __init__
    port=port, charset='utf8', **opts)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2005, "Unknown MySQL server host 'bar@localhost' (2)")

Pity.. my password is foo@bar


--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

RjOllos

unread,
May 13, 2013, 3:58:03 AM5/13/13
to trac-...@googlegroups.com
The documentation says "Note that due to the way the above string is parsed, the "/" and "@" characters cannot be part of the password.". However, I'm not sure that is the whole story.

It appears that the thing to do here is URL encode the "@":

foo@bar -> foo%40bar


Let me know if it works, and if so, I think we should add a note to the documentation. 

xiangjun

unread,
May 13, 2013, 5:30:07 AM5/13/13
to trac-...@googlegroups.com
yes, it works; many thanks!


--

RjOllos

unread,
May 13, 2013, 7:40:14 PM5/13/13
to trac-...@googlegroups.com
On Monday, May 13, 2013 2:30:07 AM UTC-7, xiangjun zhang wrote:
yes, it works; many thanks!


I'm not sure it is exactly the ideal location for the hint, but if not someone else will probably come along and do better. 
Reply all
Reply to author
Forward
0 new messages