安装mysql之前要remove掉系统自带的mysql:
rpm -qa | grep "MySQL*"    和rpm -qa | grep mysql  要确保卸载干净
rpm -e MySQL-server-5.1.74-1.el6.x86_64.rpm --nodeps
mysql这里使用rpm 安装:
安装包:MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar
tar xf MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar
解压出:
[root@vm-mha-slave02 mysql_install_packet]# ll
total 619196
-rw-r--r-- 1 root root  317030400 Aug 20 11:55 MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 wheel  23142383 Jul 16 01:16 MySQL-client-5.6.26-1.linux_glibc2.5.x86_64.rpm
-rw-r--r-- 1 7155 wheel   4586909 Jul 16 01:16 MySQL-devel-5.6.26-1.linux_glibc2.5.x86_64.rpm
-rw-r--r-- 1 7155 wheel 117649695 Jul 16 01:17 MySQL-embedded-5.6.26-1.linux_glibc2.5.x86_64.rpm
-rw-r--r-- 1 7155 wheel  88754725 Jul 16 01:17 MySQL-server-5.6.26-1.linux_glibc2.5.x86_64.rpm
-rw-r--r-- 1 7155 wheel   2418592 Jul 16 01:18 MySQL-shared-5.6.26-1.linux_glibc2.5.x86_64.rpm
-rw-r--r-- 1 7155 wheel   5181237 Jul 16 01:18 MySQL-shared-compat-5.6.26-1.linux_glibc2.5.x86_64.rpm
-rw-r--r-- 1 7155 wheel  75283535 Jul 16 01:18 MySQL-test-5.6.26-1.linux_glibc2.5.x86_64.rpm
 
先创建用户:
groupadd mysql                        --创建mysql用户组
useradd -M -s  /sbin/nologin mysql -g mysql  --这里创建的mysql不能登录没有家目录
 
rpm逐一安装:
rpm -ivh  MySQL-client-5.6.26-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.26-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.26-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-shared-5.6.26-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.26-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.x86_64.rpm
这里test不用安装了!
 
更改数据目录:
mkdir /mysqldata
将rpm默认安装的数据目录下的文件都移动到新目录下面:
mkdir -p /mysqldata/
mv /var/lib/mysql/* /mysqldata/
cd /mysqldata
mkdir slowlog
mkdir binlog
mkdir relaylog
mkdir tmpdata
mkdir general_log
chown -R mysql:mysql /mysqldata
 
更改my.cnf文件:
使用下列内容替换原有/etc/my.cnf内容,具体参数要根据应用需求和服务器情况进行调整:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
#使用本配置之前请在数据目录新建一下目录: tmpdata  binlog  relaylog general_log  slowlog ,并且赋予mysql用户权限!
 
 
[mysqld]
port=3306
datadir=/mysqldata/
tmpdir=/mysqldata/tmpdata
socket=/mysqldata/mysql.sock
skip_external_locking
open_files_limit = 65535
lower_case_table_names = 1
 
#### skip domain hostname ###########
skip-name-resolve
 
#### bin-log ########################
server-id=1
log-bin=/mysqldata/binlog/mysql-bin.index
max_binlog_size=128M
binlog-format=row
sync_binlog=1
#binlog-ignore-db=mysql
#replicate-ignore-db=mysql
#master-connect-retry=60
 
#### relay log ######################
#relay_log = /mysqldata/relaylog/mysql-relay
#relay_log_purge = 1
#expire_logs_days=3
#skip_slave_start
 
#### character ######################
character-set-server=utf8
#init_connect='SET NAMES utf8'
 
#### connect ########################
max_connections=1024
max_allowed_packet=16M
 
#### timeout ########################
wait_timeout=1024
interactive_timeout=1024
 
#### vaiables size ##################
tmp_table_size=64M
max_heap_table_size = 64M
key_buffer_size=128M
 
table_definition_cache=1024
table_open_cache=1024
join_buffer_size=4M
sort_buffer_size=4M
read_buffer_size=8M
myisam_sort_buffer_size = 64M
 
thread_cache_size = 16
thread_concurrency = 32
 
explicit_defaults_for_timestamp = 1
sysdate-is-now
 
 
########## general_log ############
#general_log=ON
#general_log_file=/mysqldata/general_log/general_log.log
 
############# slow_log ############
#default OFF
long_query_time=3
slow_query_log=1
slow_query_log_file=/mysqldata/slowlog/slow-query.log
log_queries_not_using_indexes=1
 
 
 
########## query_cache ############
#default OFF
#explicit_defaults_for_timestamp=true
query_cache_type=0
query_cache_size=0
#thread_cache = 500
#query_cache_limit=2M
 
 
########### innodb ################
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_buffer_pool_instances = 8
innodb_buffer_pool_size = 2G
innodb_additional_mem_pool_size =32M
innodb_thread_concurrency = 32
 
innodb_file_per_table=1
innodb_data_home_dir=/mysqldata
innodb_data_file_path=ibdata1:12M:autoextend
 
innodb_io_capacity = 2000
innodb_autoinc_lock_mode = 2
innodb_locks_unsafe_for_binlog = 1
transaction-isolation = READ-COMMITTED
 
 
innodb_log_file_size = 128M
innodb_log_buffer_size = 32M
innodb_log_files_in_group = 3
 
innodb_lock_wait_timeout=60
innodb_flush_method=O_DIRECT
innodb_purge_threads=1
innodb_support_xa=1
innodb_flush_log_at_trx_commit = 1
 
 
[client]
default-character-set=utf8
 
 
 
[mysql]
socket=/mysqldata/mysql.sock
 
no_auto_rehash
prompt = "\\R:\\m:\\s \\d> "
 
[mysqldump]
socket=/mysqldata/mysql.sock
 
 
添加mysql服务到开机启动:
chkconfig --add mysql
chkconfig --levels 235 mysql on
最后vi /etc/init.d/mysql  修改basedir和datadir为下面内容:
basedir=/usr
datadir=/mysqldata
 
service mysql start
cat /root/.mysql_secret
mysql -uroot -p'5P19xzxfIPUWyxwR'   --这个密码为mysql_secret里面的
SET PASSWORD = PASSWORD('mysteel');
flush privileges;
drop database test;

Linux 上通过rpm安装mysql的更多相关文章

  1. 学习 Mysql - 在linux上使用yum安装MySQL

    1.检查已经安装的mysql信息 yum list installed mysql*rpm -qa | grep mysql* 2.列出已安装和可安装的mysql信息 yum list mysql* ...

  2. 【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)

    RAC在LINUX上使用NFS安装前准备(六) 概述:写下本文档的初衷和动力,来源于上篇的<oracle基本操作手册>.oracle基本操作手册是作者研一假期对oracle基础知识学习的汇 ...

  3. Linux centos7环境下安装MySQL的步骤详解

    Linux centos7环境下安装MySQL的步骤详解 安装MySQL mysql 有两个跟windows不同的地方 1).my.ini 保存到/etc/my.ini 2).用户权限,单独用户执行 ...

  4. 在CentOS7上通过RPM安装实现LAMP+phpMyAdmin过程全记录

    在CentOS7上通过RPM安装实现LAMP+phpMyAdmin过程全记录 时间:2017年9月20日 一.软件环境: IP:192.168.1.71 Hostname:centos73-2.sur ...

  5. 大数据学习——Linux上常用软件安装

    4.1 Linux系统软件安装方式 Linux上的软件安装有以下几种常见方式: 1.二进制发布包 软件已经针对具体平台编译打包发布,只要解压,修改配置即可 2.RPM发布包 软件已经按照redhat的 ...

  6. 【转】【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)

    原文地址:http://www.cnblogs.com/baiboy/p/orc6.html 阅读目录 目录 介绍 下载软件 操作系统安装 Oracle安装先决条件 创建共享磁盘 参考文献 相关文章 ...

  7. linux下使用yum安装mysql、tomcat、httpd

    一.linux下使用yum安装mysql   1.安装 查看有没有安装过:           yum list installed mysql*           rpm -qa | grep m ...

  8. JProfiler远程监控Linux上Tomcat的安装过程细讲(步骤非常详细!!!)

    JProfiler远程监控Linux上Tomcat的安装过程细讲(步骤非常详细!!!) 1.文件准备: 服务器:CentOS Linux release 7.3.1611 (Core)     Apa ...

  9. [mysql] linux下使用yum安装mysql

    From: http://www.2cto.com/database/201207/141878.html linux下使用yum安装mysql   1.安装 查看有没有安装过:           ...

随机推荐

  1. MongoDB基本命令使用

    成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操作. 输入help可以看到基本操作命令: show dbs:显示数据库列表 show collections:显示 ...

  2. 遍历list,字典

    private void Form1_Load(object sender, EventArgs e) { List<int> ids = new List<int>(); i ...

  3. wcf 入门示例

    刚开始学习wcf,根据官方网站的说明写下的代码 第一步: 建立一个类库项目GettingStartedLib,首先添加wcf引用System.ServiceModel; 添加接口ICalculator ...

  4. Android--点击EditText的时候弹出软键盘,点击EditText之外空白处软键盘消失

    在android中点击EditText的时候会弹出软键盘,但当我们输入完毕或者想隐藏软键盘时,我们可以点击软键盘上的隐藏按钮,这种方法固然可行,但是为了提高用户体验,我们常常要实现这种功能:当输入完毕 ...

  5. 修改NameNode端口后,hive表查询报错

    在进行使用hive查询表数据的时候,抛出异常 hive> select*from blackList;FAILED: SemanticException Unable to determine ...

  6. centos7 firefox 安装flash

    在官网下载flash的tar包 https://get.adobe.com/flashplayer/?spm=a2h0j.8191423.movie_player.5~5~5~8~A 在下载tar包的 ...

  7. Debian NAT共享上网

    如果Linux主机有两个网卡,比如一个有线.一个无线,当无线连接后,其他机器即可通过有线共享上网,为了方便叙述,假设环境如下: A机器有两块网卡,eth0和ws0,其中ws0为无线网卡,已连接wifi ...

  8. nginx 的uri、request_uri 区别

    在nginx中有几个关于uri的变量,包括$uri $request_uri $document_uri,下面看一下他们的区别 : $request_uri: /stat.php?id=1585378 ...

  9. 07 nginx Location之正则匹配

    一:Location之正则匹配 再来看,正则也来参与. location / { root   /usr/local/nginx/html; index  index.html index.htm; ...

  10. 09 Memcached 分布式之取模算法的缺陷

    一: Memcached 分布式之取模算法的缺陷(1)假设你有8台服务器,运行中突然down一台,则求余数的底数就7. 后果: key_0%8==0 ,key_0%7==0 =>hist(命中) ...