mysql 5.6 for linux (rpm包安裝)
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..[確定]
全文結束