一、CentOS 7 下源码安装Python3.7.3
解决依赖
yum -y update # 更新系统环境
yum groupinstall "Development tools" # 安装开发工具包
yum -y install zlib-devel bzip2-devel bzip2-libs libffi-devel \
openssl-devel ncurses-devel sqlite-devel readline-devel \
tk-devel gcc make openssl-static patch gdbm-devel \
libpcap-devel xz-devel gcc-c++ libstdc++-devel
下载Python安装包
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
解压Python压缩安装包,配置编译并安装
tar -xvzf Python-3.7.3.tgz
cd Python-3.7.3/
./configure --prefix=/usr/local/python37 --enable-optimizations
make
make install
配置环境变量
方法一:
- 将Python3的执行路径添加到PATH环境变量中,修改
/etc/profile
文件,添加如下内容:
export PATH=/usr/local/python37/bin:$PATH
- 执行
source /etc/profile
使设置生效
方法二:
- 在/usr/local/bin中添加python3的软连接
ln -s /usr/local/python37/bin/python3 /usr/local/bin/python3
执行测试
- 命令行中执行
python3
,如果有如下信息则证明安装成功
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
- 如果提示
-bash: python3: command not found
则表示安装失败,或配置失败
问题记录
- 执行
make install
时报错 ModuleNotFoundError: No module named '_ctypes
的解决办法
- 执行
yum install libffi-devel -y
命令,python3.7以后依赖libffi-devel
- 若在安装前移除了/usr/bin下python的文件链接依赖,此时yum无法正常使用,需要自己下载相关软件包安装
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm
rpm -ivh libffi-devel-3.0.13-18.el7.x86_64.rpm
- 重新执行
make install
命令
二、CentOS 7 下 yum安装 MySQL5.7.25
获取MySQL yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
安装MySQL yum源
rpm -ivh mysql57-community-release-el7-7.noarch.rpm
安装MySQL
yum -y install mysql-community-server
启动MySQL服务
service mysqld start
获取临时密码
grep "password" /var/log/mysqld.log
使用临时密码登录
mysql -uroot -p
修改用户密码
ALTER USER root@localhost IDENTIFIED BY "password"
- 执行
exit
退出mysql命令行,使用新密码重新登录MySQL
mysql -uroot -p
允许远程登录MySQL,修改/etc/my.cnf配置文件,添加以下内容:
bind-address=0.0.0.0
grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;
flush privileges;
防火墙过滤80端口
firewall-cmd --permanent --zone=public --add-port=3306/tcp # 添加通过端口及协议
firewall-cmd --reload # 重新加载配置
网友评论