mysql 5.6 for linux (rpm包安裝)

lcl150800發表於2016-08-02
mysql 5.6 rpm包 for linux 安裝
安裝系統,並關閉selinux與iptables
1 關閉selinux 修改selinux配置檔案(重啟伺服器生效)
[root@mysql1 ~]# vi /etc/selinux/config 


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 
2 管理iptables(重啟伺服器生效)
停止iptables
[root@mysql1 ~]# /etc/init.d/iptables stop
關閉iptables開機啟動
[root@mysql1 ~]# chkconfig --list iptables
iptables        0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉
3 查詢系統是否存在mysql殘存包如果存在刪除處理,以保證mysql安裝無問題。
查詢
[root@mysql1 install]# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64
存在並刪除
[root@mysql1 install]# rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
4 安裝mysql相關檔案
安裝server
[root@mysql1 install]# rpm -ivh MySQL-server-5.6.29-1.rhel5.x86_64.rpm 
warning: MySQL-server-5.6.29-1.rhel5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
安裝devel
[root@mysql1 install]# rpm -ivh MySQL-devel-5.6.29-1.rhel5.x86_64.rpm 
warning: MySQL-devel-5.6.29-1.rhel5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
安裝 client
[root@mysql1 install]# rpm -ivh MySQL-client-5.6.29-1.rhel5.x86_64.rpm 
warning: MySQL-client-5.6.29-1.rhel5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
5 有中文存放mysql資料庫 修改引數檔案(手動建立即可)
[root@mysql1 install]# vi /etc/my.cnf
[client]
#客戶端字符集
default-character-set=utf8
[mysqld]
#字符集
character-set-server=utf8
#不區分大小寫
lower_case_table_names=1
[mysql]
#字符集
default-character-set=utf8
6 啟動mysql服務
[root@mysql1 install]# /etc/init.d/mysql start
7 修改登入密碼
初始密碼位置為安裝使用者根目錄下
[root@mysql1 ~]# cat /root/.mysql_secret 
# The random password set for the root user at Thu Jul 28 14:31:34 2016 (local time): 903yX2XlB1edVpua
8 登入並修改密碼
[root@mysql1 ~]# mysql -uroot -p903yX2XlB1edVpua
mysql> set password=password('oracle');
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql;
mysql> UPDATE user SET Password = password('oracle') WHERE User = 'root' ;
mysql> flush privileges;
mysql> exit
9 修改預設資料檔案路徑
建立目錄
[root@mysql1 ~]# cd /home/
[root@mysql1 home]# mkdir mysql
停止mysql服務
[root@mysql1 home]# /etc/init.d/mysql stop
Shutting down MySQL..[確定]
10 CP 資料檔案至新路徑
[root@mysql1 home]# cp -r /var/lib/mysql/ /home/mysql/
修改my.cnf檔案與/etc/init.d/mysql檔案
my.cnf檔案新增socket路徑
[root@mysql1 home]# vi /etc/my.cnf
[client]
#客戶端字符集
default-character-set=utf8
socket = /home/mysql/mysql.sock
[mysqld]
socket = /home/mysql/mysql.sock
#字符集
character-set-server=utf8
#不區分大小寫
lower_case_table_names=1
[mysql]
#字符集
default-character-set=utf8
auto-rehash
修改mysql檔案中datadir路徑資訊
[root@mysql1 home]# vi /etc/init.d/mysql 
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.


basedir=
datadir=/home/mysql/


修改新建mysql儲存目錄許可權(試過755和775都報錯 只有賦值777時啟動無問題,不知道什麼原因)
[root@mysql1 home]# chmod -R 777 mysql/
[root@mysql1 home]# /etc/init.d/mysql start
Starting MySQL..[確定]


全文結束

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22390488/viewspace-2122857/,如需轉載,請註明出處,否則將追究法律責任。

相關文章