centos搭建python2.7开发环境
pip升级
#centos7 默认python版本2.7.5
yum -y install python-pip
#默认安装的pip版本为
以上方法会报错
#下载get-pip.py
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
以上方法可以把pip8升级到pip20
安装mysql
下载MySQL仓库并安装
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
yum -y install mysql80-community-release-el7-3.noarch.rpm
3.默认安装MySQL8.0,如果需要安装MySQL5.7的话需要修改/etc/yum.repos.d/mysql-community.repo配置文件
将mysql80中enabled属性改为0,并添加图中红框内代码(安装MySQL8.0跳过该步骤)
4.安装MySQL数据库
yum -y install mysql-community-server
5.开启mysql服务
systemctl start mysqld.service
6.查看mysql默认密码并登陆
cat /var/log/mysqld.log | grep password
mysql -uroot -p
安装python-mysql会出错
在执行pip install MySQL-python
时报错如:
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法
缺少mysql-develyum install -y mysql-devel
如果不行请执行以下安装更多yum install -y python-devel mysql-devel redhat-rpm-config gcc
亲测有效
可能会出现这个错误
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately
换阿里源就可以解决问题了
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --ignore-installed
安装mysql-linux时候的错误
linux-Mysql安装出错-The GPG keys listed for the “MySQL 5.7 Community Server“ repository are already...
Failing package is: mysql-community-server-5.7.37-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决方式:
以2022年为例
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum安装redis
sudo
yum
install
epel-release yum-utils
sudo
yum
install
http:
//rpms
.remirepo.net
/enterprise/remi-release-7
.rpm
sudo
yum-config-manager --
enable
remi
sudo
yum
install
redis
设置开机启动
sudo
systemctl
enable
redis
启动
sudo
systemctl start redis
设置pycharm连接远程服务器
PyCharm远程连接服务器简明教程 - 知乎 (zhihu.com)
安装mongodb,我们安装的是mongodb-org4.0版本
一步步执行下列命令即可:
1.添加源
cat << EOF | sudo tee -a /etc/yum.repos.d/mongodb-org-4.0.repo [mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc EOF
2.安装
yum install -y mongodb-org
3.更改参数(可选,启用集群部署)
sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.conf
sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
4.启动服务并设置为开机自启
systemctl enable mongod && systemctl start mongod
* 如果使用了第3步,则需执行以下命令:
mongo --eval "printjson(rs.initiate())"