搭建前的準備node
輸入: rpm -qa | grep mysql 查看數據庫是否安裝了數據庫若是隻出現這個:mysql-libs-5.1.73-8.el6_8.x86_64,能夠不用管, 若是出現:mysql-server-5.1.73-8.el6_8.x86_64 等等,須要把它刪除 rpm -e mysql // 普通刪除模式 rpm -e --nodeps mysql // 強力刪除模式,若是使用上面命令刪除時,提示有依賴的其它文件,則用該命令能夠對其進行強力刪除 在刪除完之後咱們能夠經過 rpm -qa | grep mysql 命令來查看mysql是否已經卸載成功!!其實就是剛纔的步驟。
**開始 yum 安裝mysql **mysql
一、 經過yum來進行mysql的安裝 yum list | grep mysql ,yum上提供的mysql數據庫可下載的版本, mysql-libs.x86_64 5.1.71-1.el6 @anaconda-CentOS-201311291202.x86_64/6.5 apr-util-mysql.x86_64 1.3.9-3.el6_0.1 os asterisk-mysql.x86_64 1.8.32.3-2.el6 epel bacula-director-mysql.x86_64 5.0.0-13.el6 os bacula-storage-mysql.x86_64 5.0.0-13.el6 os collectd-mysql.x86_64 4.10.9-4.el6 epel dmlite-plugins-mysql.x86_64 0.8.6-2.el6 epel dovecot-mysql.x86_64 1:2.0.9-22.el6 os dpm-copy-server-mysql.x86_64 1.9.0-1.el6 epel dpm-name-server-mysql.x86_64 1.9.0-1.el6 epel dpm-server-mysql.x86_64 1.9.0-1.el6 epel dpm-srm-server-mysql.x86_64 1.9.0-1.el6 epel dspam-mysql.x86_64 3.10.2-7.el6 epel exim-mysql.x86_64 4.89-1.el6 epel freeradius-mysql.x86_64 2.2.6-6.el6_7 os . . . (能夠看到個人是5.1的版本), 二、 安裝服務端:yum install -y mysql-server mysql mysql-deve // (網上說法)mysql-deve 主要是供本身寫C程序用的頭文件和靜態連接庫, 若是不做C開發,能夠不裝。任何-devel包都是這樣, 出現 Complete! 則安裝結束。 三、查看服務端版本 : rpm -qi mysql-server ,能看到如下信息 Name : mysql-server Relocations: (not relocatable) Version : 5.1.73 Vendor: CentOS Release : 8.el6_8 Build Date: Fri Jan 27 06:25:43 2017 Install Date: Wed Jun 21 11:13:02 2017 Build Host: c1bm.rdu2.centos.org Group : Applications/Databases Source RPM: mysql-5.1.73-8.el6_8.src.rpm Size : 25884131 License: GPLv2 with exceptions Signature : RSA/SHA1, Fri Jan 27 06:35:28 2017, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://www.mysql.com Summary : The MySQL server and related files 四、 首次啓動mysql : service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h VM_102_32_centos password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ] 五、設置開機啓動 : chkconfig mysqld on 六、由於初次安裝是沒有密碼的,默認用戶是 root ,從上面語打印的信息能夠看到,咱們須要給root 用戶設置一個密碼 /usr/bin/mysqladmin -u root password 'new-password' 只須要執行這句就能夠 : mysqladmin -u root password '123456' //123456 就是 root的密碼 七、此時mysql 已經安裝成功了,其餘更詳細的配置你們能夠本身查資料瞭解,服務器通常不打開數據庫的3306端口,若是須要工具遠程鏈接數據庫,能夠試用ssh方式鏈接數據庫