提示:由於centos7.2默認安裝了mariadb-libs,因此先要卸載掉:node
#查看是否安裝mariadb rpm -qa | grep mariadb
# 卸載mariadb(注意檢查依賴,判斷是否能夠強制刪除) rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
OK,python
一、開始,Linux系統自帶的repo是不會自動更新每一個軟件的最新版本(基本都是比較靠後的穩定版),因此沒法經過yum方式安裝MySQL的高級版本。因此咱們須要先安裝帶有當前可用的mysql5系列社區版資源的rpm包。mysql
##安裝rpm包 [root@brad ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
二、查看當前可用的mysql安裝資源:sql
[root@brad ~]# yum repolist enabled | grep "mysql.*-community.*"
從上面的列表能夠看出, mysql56-community/x86_64
和 MySQL 5.6 Community Server
能夠使用。數據庫
所以,咱們就能夠直接用yum方式安裝了MySQL5.6版本了。centos
[root@brad ~]# yum -y install mysql-community-server
三、MySQL安裝完成後,進行相關配置。安裝完MySQL後,須要進行一些基礎配置工做:centos7
#######安裝成功後,將其加入開機啓動 [root@brad ~]# systemctl enable mysqld #######啓動mysql服務進程 [root@brad ~]# systemctl start mysqld #######配置mysql(設置密碼等) [root@brad ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y [設置root用戶密碼] New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! 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. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y [刪除匿名用戶] ... Success! 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? [Y/n] y [禁止root遠程登陸] ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y [刪除test數據庫] - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y [刷新權限] ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up...
四、安裝mysql-python以及一些簡單的錯誤處理:spa
#在虛擬環境下安裝mysql-pyhon pip install mysql-python
一些錯誤處理:code
#安裝依賴 yum install kernel-devel libxslt-devel libffi-devel python-devel mysql-devel zlib-devel openssl-devel -y