第1章 概述

Dataviz在部署的时候需要一个数据库来运行支撑库,有时候就需要在客户的Linux环境上安装MySQL。

第2章 安装步骤

  1. 获取mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz,并把mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz上传到 /usr/local
  2. 检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称) rpm -qa | grep -i mysql
    mysql-libs-5.1.66-2.el6_3.x86_64
    
    yum -y remove mysql-libs*
  3. 进入usr/local/目录 cd /usr/local/
  4. 解压 tar -zxvf mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
  5. 重命名文件夹名称 mv mysql-5.5.57-linux-glibc2.12-x86_64 mysql
  6. 添加系统mysql组和mysql用户 groupadd mysql useradd -r -g mysql mysql
  7. 进入mysql目录 cd mysql
  8. 修改当前目录拥有者为mysql用户 chown -R mysql:mysql ./
  9. 进入support-files目录,查看是否有my_default.cnf文件 cd support-files / ll ./MySQL_on_linux/1
  10. 如果没有,则需要创建一个my_default.cnf文件上传到/usr/local/mysql/support-files目录下。文件内容如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]



sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 


basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /var/run/mysqld/mysqld.sock
character-set-server=utf8


back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M

max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8

thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6


server_id=1

innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M


innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on

[mysqldump]
quick

max_allowed_packet = 32M

[mysql]
no-auto-rehash
default-character-set=utf8
safe-updates

[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 8192

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
  1. 安装数据库 cd .. ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
  2. 复制配置文件,提示是否覆盖 输入“Y” cp support-files/my-default.cnf /etc/my.cnf
  3. 添加开机启动,提示是否覆盖 输入“Y” cp support-files/mysql.server /etc/init.d/mysql
  4. 修改启动脚本 vi /etc/init.d/mysql
  5. 修改项: basedir=/usr/local/mysql/ datadir=/usr/local/mysql/data/mysql
  6. 创建socket目录,并授权 mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld
  7. 启动服务 service mysql start
  8. 查看是否启动成功 ps -ef|grep mysql ./MySQL_on_linux/2
  9. 加入环境变量,这样可以在任何地方用mysql的命令了 export PATH=$PATH:/usr/local/mysql/bin source /etc/profile

  10. 修改root账户密码 mysqladmin -u root password '密码'

  11. 连接mysql mysql –uroot –p
  12. 输入密码后连进入控制台

./MySQL_on_linux/3

  1. 修改可远程访问 set sql_safe_updates=0; use mysql update user set host = '%' where user = 'root'; flush privileges; exit
  2. 如果有防火墙还需要修改防火墙的配置,开通3066端口 vi /etc/sysconfig/iptables
  3. 添加一行 -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
  4. 重启防火墙 service iptables restart

results matching ""

    No results matching ""