当我在virtualenv中运行mysqld
时,我收到错误并中止消息。
(nettuts)sez@sez-laptop:~/.virtualenvs$ mysqld
111220 15:22:59 [Warning] Can't create test file /var/lib/mysql/sez-laptop.lower-test
111220 15:22:59 [Warning] Can't create test file /var/lib/mysql/sez-laptop.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
111220 15:22:59 [ERROR] Aborting
111220 15:22:59 [Note] mysqld: Shutdown complete
首先我尝试用
安装MySQL-pythonpip install -E default/ MySQL-python
那给了我
Requirement already satisfied (use --upgrade to upgrade): '
MySQL-python in ./default/lib/python2.7/site-packages
Cleaning up...
然后当我检查它是否安装时,它显示它不是
(nettuts)sez@sez-laptop:~/.virtualenvs$ pip freeze
Django==1.3.1
wsgiref==0.1.2
然后我决定用pip install MySQL-python
安装它,它安装得很好,因为它显示
(nettuts)sez@sez-laptop:~/.virtualenvs$ pip freeze
Django==1.3.1
MySQL-python==1.2.3
wsgiref==0.1.2
如何让MySQL-python
在virtualenv中正常运行?
更新
当我运行sudo invoke-rc.d mysql start
时,这就是我得到的
(nettuts)sez@sez-laptop:~/.virtualenvs/nettuts$ sudo invoke-rc.d mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
然后,当我按照指示运行start mysql
时,这就是我得到的
(nettuts)sez@sez-laptop:~/.virtualenvs/nettuts$ sudo start mysql
start: Job is already running: mysql
那真正发生了什么?
答案 0 :(得分:1)
它与Python和virtualenv没有任何关系。您的mysqld未配置为在普通用户的权限下正常运行 - 需要使用您的发行版普通服务启动机制(例如Ubuntu上的sudo invoke-rc.d mysql start
)调用它。
答案 1 :(得分:0)