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..[确定]
全文结束
网页标题:mysql5.6forlinux(rpm包安装)
网站网址:
http://shouzuofang.com/article/gdcdcg.html