阿里云服务器(Ubuntu) python2+django框架+远程连接mysql数据库 (纯命令行操作)

先安装配置环境python2和pip3

详情见:https://blog.csdn.net/weixin_40490238/article/details/82181518

安装最新版django

pip install django


#检查安装是否成功
$python
>>import django
>>django.VERSION

安装mysql

apt-get install mysql-server mysql-client

#然后设置mysql密码

#测试是否安装成功

$ mysql -u root -p
#出现mysql命令行则安装成功

安装libmysqlclient-dev

apt-get install libmysqlclient-dev

#更新数据库
updatedb

可输入命令【locate mysql_config】可查看 mysql_config 的所在路径

安装mysql-python

pip install mysql-python

至此,环境安装完成!

远程访问mysql

#创建远程访问用户
create user test identified by '123456';

#对该用户进行授权
grant all privileges on *.* to 'test'@'%'identified by '123456' with grant option;

#刷新用户权限表
flush privileges ;

远程连接并不成功,应修改配置文件

文件目录为:  /etc/mysql/mysql.conf.d/

第43行修改:注释掉

bind-address		= 127.0.0.1
改为
#bind-address		= 127.0.0.1

远程连接成功!

参考文献:

配置:

https://blog.csdn.net/Houchaoqun_XMU/article/details/68060158

https://www.linuxidc.com/Linux/2016-02/128714.htm

远程:

https://blog.csdn.net/li_101357/article/details/69395974

https://www.cnblogs.com/codeAB/p/6391022.html

猜你喜欢

转载自blog.csdn.net/weixin_40490238/article/details/82348170
今日推荐