django、phpmyadmin 和 mysql?
我想开始使用 Django 和 MYSQL,而不是一直使用 sqlite,但是我使用 MSQL 的唯一经验是通过 XAMPP,通过 phpmyadmin 操作数据库。我真的很想保持与 mysql 的 GUI 交互,而不必通过命令行完成所有操作。
您可以使用xampp/phpmyadmin启动和管理MYSQL数据库,然后仅使用Django的sn开发服务器将django用于Web开发端吗?
或者你是否必须始终通过命令行启动新数据库,如果是这样,它是如何完成的,请记住我只通过 xampp/phpmyadmin 使用 mysql?
我知道如何通过 django 链接和管理数据库,我只是不知道如何通过它启动 mysql 数据库,而且我真的不想失去 xampp/phpmyadmin 附带的 mysql gui。非常感谢所有帮助。
I would like to start using Django with MYSQL, instead of sqlite all the time, however my only experience using MSQL is through XAMPP, manipulating databases through phpmyadmin. I would really like to keep this gui interaction with mysql and not have to do everything through command line.
Can you start and manage a MYSQL database using xampp/phpmyadmin, and then use django for the web development side only using Django'sn development server?
Or do you have to always start new databases through command line, and if so how is it done, bearing in mind I only ever use mysql through xampp/phpmyadmin?
I know how to link and manage a database through django, I just dont know how to start a mysql one through it, and I dont really want to have to loose the mysql gui that comes with xampp/phpmyadmin. all help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你绝对可以通过XAMPP界面来管理Mysql。尝试将 settings.py 中的 DB_HOST 设置为“localhost”。如果不起作用,请尝试“127.0.0.1”。这通常是由于 python-mysql 模块期望 mysql unix 套接字位于其他位置而导致的。实际上,我不确定 mysql 服务器是否在 Windows 上使用 unix 套接字。无论如何,两者之一都应该有效:)
您也可以使用用于登录 phpmyAdmin 的凭据来登录 Django。许多人认为使用 root 来执行非管理任务是不好的方式(我同意),但对于初学者和您的开发机器来说,这并不是什么大问题。
phpMyAdmin 应该可以与 django 管理的数据库一起使用。
我的 mysql 数据库 settings.py 块看起来像这样:
This is for django 1.2 and above.将 DBNAME、USER 和 PASSWORD 替换为相应的值,如果遇到问题,请尝试使用“127.0.0.1”作为主机。显然,您需要像使用 sqlite 一样运行“manage.pysyncdb”,然后才能使用它。
You can definitely manage Mysql through the XAMPP interface. Try setting the DB_HOST in settings.py to "localhost". If it doesn't work, try "127.0.0.1". This is typically caused by the python-mysql module expecting the mysql unix socket to be in another place than it is. Actually, I'm unsure if the mysql server uses a unix socket on Windows. Anyway, one of both should work :)
You can use the credentials you use to login with phpmyAdmin also for Django. Many consider it bad style to use root for non-administration tasks (and I agree), but for starters and on your development machine it isn't too big of an issue.
phpMyAdmin should work out of the box with your django-managed databases.
My database settings.py block for mysql looks something like this:
This is for django 1.2 and above. Replace DBNAME, USER and PASSWORD with the respective values and try '127.0.0.1' as HOST if you run into problems. Obviously, you'd need to run 'manage.py syncdb' as you did with sqlite before you can use it.
我强烈建议您查看 postgresql!它配备了一个类似 Sqlserver 管理系统的数据库浏览器,可以在桌面上运行,而不是基于 Web 的前端。现在您无需担心与 Django 一起配置 PHP。在 XAMPP 上安装 Postgresql 可能比 MySql 更难,但我相信这样做可以让您受益匪浅。
Postgresql 也比 MySQL 好很多(在我看来),根据许多熟悉 Django 的人的说法,Postgresql 是与 Django 一起使用的推荐数据库。
也就是说,我目前使用 Oracle,所以你可能不应该听我的。 :)
I'd highly recommend checking out postgresql! It comes with a Sqlserver-Management-System-like Database Browser that runs on your desktop, rather than a web based front end. Now you don't need to worry about configuring PHP alongside Django. Postgresql will probably be harder to install than MySql on XAMPP, but I believe that you can get a lot out of doing so.
Postgresql is also a lot better (IMO) than MySQL, and is the recommended database to use with Django according to a lot of the people close to Django.
That said, I currently use Oracle, so you probably shouldn't listen to me. :)
您可以使用 phpMyAdmin 轻松管理您的数据库。 Django 需要的只是数据库的权限和访问信息。一旦这些设置完成(在 phpMyAdmin 中授予权限并在 Django 的 settings.py 中添加访问信息),您将发出一个
manage.pysyncdb
例如,您就完成了。You can easily manage your databases with phpMyAdmin. All what Django needs is permission and access information for your database. Once those are set up (granting permissions in phpMyAdmin and adding the access information in Django's settings.py), you would issue a
manage.py syncdb
for example and you're done.