Centos6.7普通用户二进制安装mariadb10

   1.root登陆建立普通用户
        groupadd -g 150 mariadb
        uaeradd -u 150 mariadb -g -c 'MySQL Server' mariadb //-c 添加描述
        password mariadb
        su mariadb
        mkdir src usr
 

 
   2.下载二进制mariadb包
        wget http://mirrors.opencas.cn/mariadb//mariadb-10.0.22/bintar-linux-x86_64/mariadb-10.0.22-linux-x86_64.tar.gz
        tar -zxvf mariadb-10.0.22-linux-x86_64.tar.gz
        mv mariadb-10.22-linux-x86_64    3306 //可以创建多实例
        cd 3306
   3.进入3306目录建立如下目录
        data数据目录已经存在
        logs存放bin-log文件
        tmp存放

   4.进入scipts目录下根据自己服务器拷贝(拷贝3306当前目录下命名my.cnf如下是实例)
[client]
port            = 3306
socket          = /home/mariadb/usr/3306/tmp/mysql.sock //sock存放问题
default-character-set=utf8  //设置字符集的时候mysql5.1中client和mysqld添加是同样参数default-character-set=utf8到5.5就变了

[mysqld]
port            = 3306
socket          = /home/mariadb/usr/3306/tmp/mysql.sock
lower_case_table_names=1 //1不区分大小写 0区分大小写
character-set-server=utf8
user            = mariadb
back_log = 50

max_connections = 65535

max_connect_errors = 10

table_open_cache = 2048

max_allowed_packet = 16M

binlog_cache_size = 1M

max_heap_table_size = 64M

read_buffer_size = 2M

read_rnd_buffer_size = 16M

sort_buffer_size = 8M

join_buffer_size = 8M

thread_cache_size = 8

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 2M

ft_min_word_len = 4

default-storage-engine = INNODB

thread_stack = 240K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 64M

datadir = /home/mariadb/usr/3306/data     //数据库目录

basedir = /home/mariadb/usr/3306        //数据库安装的目录
 
log-bin= /home/mariadb/usr/3306/logs/mysql-bin  //开启log-bin

binlog_format=mixed

pid-file = /home/mariadb/usr/3306/data/mysql.pid  //pid

slow_query_log= /home/mariadb/usr/3306/logs       //慢查询

long_query_time = 2

server-id = 1

########## myisam ##################

key_buffer_size = 32M

bulk_insert_buffer_size = 64M

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

############ innodb ########################

innodb_additional_mem_pool_size = 16M

innodb_buffer_pool_size = 2G

innodb_data_file_path = ibdata1:10M:autoextend

innodb_write_io_threads = 8
innodb_read_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 8M

innodb_log_file_size = 256M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

[mysqldump]
quick


max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 65536

 5.初始化数据库
    在初始化数据库之前要需要在var/log/mysqld.log touch这个文件
    su -
    touch /var/log/mysqld.log && chown -R mariadb:mariadb mysqld.log
    exit
    ./scripts/mysql_install_db --user=mariadb --datadir=/home/mariadb/usr/3306/data/ --defaults-file=/home/mariadb/usr/3306/my.cnf
 6.启动数据库
   bin/mysqld_safe --pid-file=/home/mariadb/usr/3306/data/mysql.pid --user=mariadb --datadir=/home/mariadb/usr/3306/data/  &
 7.关闭数据库
   bin/mysqladmin -uroot -p -S /home/mariadb/usr/3306/tmp/mysql.sock shutdown
 8.建立启动,关闭,root,普通用户脚本(启动关闭为例)
 vi srv3306.mysql
#!/bin/bash
#########################################################################
# File Name: srv3306.mysql start stop
# Author: boy
# Email: [email protected]
# Version:
# Created Time: 2015-12-04-14:02 DEC Fir
#########################################################################


####### start ##############

case "$1" in
        start)
                cd /home/mariadb/usr/3306 && bin/mysqld_safe --pid-file=/home/mariadb/usr/3306/data/mysql.pid --user=mariadb --datadir=/home/mariadb/usr/3306/data/  &
        ;;

        stop)
                cd /home/mariadb/usr/3306 && bin/mysqladmin -uroot -p -S /home/mariadb/usr/3306/tmp/mysql.sock shutdown
        ;;

        *)
                echo "Usage:start,stop"
        ;;

esac

####### end ###############
我这里数据库没有密码
chmod 755 srv3306.mysql
   


你可能感兴趣的:(二进制,用户,password)