CentOS 7升級Python3,然後安裝Mycli

2020-10-19 15:00:41

0.檢視系統版本

	cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

1.設定阿里pip倉庫

	 mkdir ~/.pip/
	 cat > ~/.pip/pip.conf <<EOF
	 [global]
	 index-url = https://mirrors.aliyun.com/pypi/simple/
	 
	 [install]
	 trusted-host=mirrors.aliyun.com
	 EOF

2.升級python

	yum -y install libffi-devel zlib* python-devel openssl-devel
	tar -zxf Python-3.9.0.tgz
	cd Python-3.9.0/
	./configure --prefix=/usr/local/python --with-ssl
	make && make install 

3.建立連結,提升易用性

	ln -s /usr/local/python/bin/python3 /usr/bin/
 	sed -i '/^PATH/s#$#:/usr/local/python/bin#' ~/.bash_profile
 	source ~/.bash_profile
	echo $PATH

4.安裝、啟動mycli

	pip3 install mycli
	systemctl status mariadb
	mycli
	# 執行mycli報錯的話可以改一下執行器
	# sed -i 's/python/python3/' /usr/bin/mycli