ubuntu
)查看當前主機名:python
hostname
修改主機名:mysql
vi/vim /etc/hostname
qw
保存退出sql
vi/vim /etc/hosts
# 在第二行添加 127.0.1.1 ubuntu(ubuntu爲你剛纔設置的主機名)
sudo reboot ---->重啓系統數據庫
vi/vim /etc/cloud/cloud.cfg
找到preserve_hostname: false
將其修改成preserve_hostname: true
ubuntu
vi/vim /etc/hostname
qw
保存退出vim
vi/vim /etc/hosts
# 在第二行添加 127.0.1.1 ubuntu(ubuntu爲你剛纔設置的主機名)
sudo reboot ---->重啓系統bash
爲何換源,換源的好處:服務器
服務器換源(ubuntu 16.04 ):markdown
sudo vi/vim/gedit /etc/apt/sources.list
#阿里源 deb http://mirrors.aliyun.com/ubuntu/ xenial main deb-src http://mirrors.aliyun.com/ubuntu/ xenial main deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security main deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
更新:app
ubuntu16.04以上版本相似於此,網上都有不在贅述。
修改軟連接實現
進入/usr/bin目錄,如不進入目錄,之後每次對文件操做要寫絕對路徑
cd /usr/bin
查看該目錄下與python有關的項
ls | grep python
查看python詳細信息
ls -l python #軟鏈接我修改了,未修改的話後面是python2.7
刪除原軟連接、創建新的指向python3的軟連接
sudo rm python sudo ln -s python3.5 python
最後結果:
Ubuntu16.04下,遇到Unmet dependencies. Try 'apt-get -f install' with no packages的解決辦法:
sudo apt-get -f install
按照相關提示進行解決。
爲何建立快照:
在配置軟件時出現問題,形成系統混亂,或者環境依賴不一樣形成沒法配置成功等。
經過apt-get 安裝Mysql服務
#先更新下 sudo apt-get update #安裝 sudo apt-get install mysql-server
注:再安裝的時候,若是是服務器會出現界面讓輸入密碼,能夠設置也能夠後面初始化的時候設置
初始化設置:
sudo mysql_secure_installation
開始配置項:
#1 VALIDATE PASSWORD PLUGIN can be used to test passwords... Press y|Y for Yes, any other key for No: N (選擇N ,不會進行密碼的強校驗) #2 Please set the password for root here... New password: (輸入密碼) Re-enter new password: (重複輸入) #3 By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them... Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (選擇N,不刪除匿名用戶) #4 Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network... Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (選擇N,容許root遠程鏈接) #5 By default, MySQL comes with a database named 'test' that anyone can access... Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (選擇N,不刪除test數據庫) #6 Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (選擇Y,修改權限當即生效)
檢查mysql服務狀態:
systemctl status mysql.service
出現如圖所示即成功:
遠程設置:找到 bind-address 修改值爲 0.0.0.0(若是須要遠程訪問)
#找到 bind-address 修改值爲 0.0.0.0(若是須要遠程訪問) sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf #重啓mysql sudo /etc/init.d/mysql restart
登陸:
sudo mysql -uroot -p 輸入密碼:****
設置權限:
#設置權限與密碼 #使用mysql_native_password修改加密規則 mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密碼'; #更新一下用戶的密碼 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '密碼' PASSWORD EXPIRE NEVER; #容許遠程訪問 mysql> UPDATE user SET host = '%' WHERE user = 'root'; #刷新cache中配置 刷新權限 mysql>flush privileges; mysql>quit;
配置開放端口3306:
打開Navicat軟件測試:
介紹:
virtualenv是虛擬環境,virtualenvwrapper
對virtualenv
的命令進行了封裝,使得其更加友好
Virtaulenvwrapper是virtualenv的擴展包,用於更方便管理虛擬環境,它能夠作: - 將全部虛擬環境整合在一個目錄下 - 管理(新增,刪除,複製)虛擬環境 - 快速切換虛擬環境
安裝:
sudo apt install python-virtualenv sudo easy_install virtualenvwrapper
pip3安裝:(推薦)
#pip3安裝: sudo pip install virtualenv sudo pip install virtualenvwrapper
pip3安裝virtualenvwrapper出現的問題:
........ raise DistutilsError(msg) distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pbr') ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-6hblrn57/virtualenvwrapper/
解決方法:
#我的使用的第一個命令就解決問題,後兩條報錯,僅供參考 sudo pip install-i https://pypi.tuna.tsinghua.edu.cn/simple pbr sudo pip install-i https://pypi.tuna.tsinghua.edu.cn/simple--no-deps stevedore sudo pip install-i https://pypi.tuna.tsinghua.edu.cn/simple--no-deps virtualenvwrapper
繼續安裝:
echo "source virtualenvwrapper.sh" >> ~/.bashrc source ~/.bashrc
建立虛擬環境:
mkvirtualenv --python=python3.8 venv
激活環境:
workon #列出虛擬環境列表 workon [venv] #切換環境
退出環境:
deactivate
刪除環境:
rmvirtualenv venv
若是後面遇到問題隨時更新或開新帖.
前人栽樹,後人乘涼;
站在巨人的肩膀上讓我能看的更遠;
借鑑網上的大佬們的方法,如下引自:
ubuntu 20.04最全的Python虛擬環境使用方法:https://blog.csdn.net/sirobot/article/details/107067577
pip安裝virtualenvwrapper報錯的解決辦法:https://www.jianshu.com/p/842eced0df69
Ubuntu20.04安裝Mysql:https://blog.csdn.net/weixin_38924500/article/details/106261971