zoukankan      html  css  js  c++  java
  • MariaDB-10.x二进制包安装

    MariaDB-10.x二进制包安装

    官方网站:

    环境:
    CentOS6.5 x64
    mariadb-10.1.10

    一.下载
    tar -xvf mariadb-10.1.10-linux-x86_64.tar.gz /opt
    ln -s /opt/mariadb-10.1.10-linux-x86_64 /opt/mariadb

    二.创建用户和组

    useradd -r -s /sbin/nologin -M mysql

    chown -R mysql: /opt/mariadb-10.1.10-linux-x86_64


    三.配置

    1.命令工具PATH和MAN PATH

    echo 'PATH=$PATH:/opt/mariadb/bin' >>/etc/profile

    source /etc/profile

    echo MANPATH /opt/mariadb/man >>/etc/man.config

    2.初始化mariadb

    http://www.canonware.com/jemalloc/

    依赖多线程内存管理

    rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

    yum -y install jemalloc

    wget https://github.com/jemalloc/jemalloc/releases/download/4.0.4/jemalloc-4.0.4.tar.bz2

    tar -xvf jemalloc-4.0.4.tar.bz2 -C /opt

    cd /opt/jemalloc-4.0.4

    ./configure && make -j4 && make -j4 install

    ldconfig


    /opt/mariadb/scripts/mysql_install_db --user=mysql --basedir=/opt/mariadb --datadir=/opt/mariadb/data

    3.init脚本

    cp /opt/mariadb/support-files/mysql.server /etc/init.d/mysql

    chmod +x /etc/init.d/mysql

    sed -i "/^basedir=/c basedir=/opt/mariadb" /etc/init.d/mysql

    sed -i "/^datadir=/c datadir=/opt/mariadb/data" /etc/init.d/mysql

    4.主配置文件

    cp -f /opt/mariadb/support-files/my-huge.cnf /etc/my.cnf

    [mysqld]

    log-error       = /opt/mariadb/mysqld.log

    pid-file        = /opt/mariadb/mysqld.pid

    在[mysqld]段增加如上两行

    5.logrotate配置文件

    cp -f /opt/mariadb/support-files/mysql-log-rotate /etc/logrotate.d/

    请按需微调

    四.启动

    chown -R mysql: /opt/mariadb-10.1.10-linux-x86_64

    service mysql start

    chkconfig mysql on

    [root@slave2 ~]# service mysql start

    Starting MySQL. SUCCESS! 

    [root@slave2 ~]# netstat -tunlp|grep mysql 

    tcp            0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      3349/mysqld 


    五.安全设置

    sed -i "/^basedir=/c basedir=/opt/mariadb" /opt/mariadb/bin/mysql_secure_installation

    [root@slave2 ~]# mysql_secure_installation 

    print: /opt/mariadb/bin/my_print_defaults


    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


    In order to log into MariaDB to secure it, we'll need the current

    password for the root user.  If you've just installed MariaDB, and

    you haven't set the root password yet, the password will be blank,

    so you should just press enter here.


    Enter current password for root (enter for none): 

    OK, successfully used password, moving on...


    Setting the root password ensures that nobody can log into the MariaDB

    root user without the proper authorisation.


    Set root password? [Y/n] 

    New password: 

    Re-enter new password: 

    Password updated successfully!

    Reloading privilege tables..

     ... Success!



    By default, a MariaDB installation has an anonymous user, allowing anyone

    to log into MariaDB without having to have a user account created for

    them.  This is intended only for testing, and to make the installation

    go a bit smoother.  You should remove them before moving into a

    production environment.


    Remove anonymous users? [Y/n] 

     ... Success!


    Normally, root should only be allowed to connect from 'localhost'.  This

    ensures that someone cannot guess at the root password from the network.


    Disallow root login remotely? [Y/n] 

     ... Success!


    By default, MariaDB comes with a database named 'test' that anyone can

    access.  This is also intended only for testing, and should be removed

    before moving into a production environment.


    Remove test database and access to it? [Y/n] 

     - Dropping test database...

     ... Success!

     - Removing privileges on test database...

     ... Success!


    Reloading the privilege tables will ensure that all changes made so far

    will take effect immediately.


    Reload privilege tables now? [Y/n] 

     ... Success!


    Cleaning up...


    All done!  If you've completed all of the above steps, your MariaDB

    installation should now be secure.


     

    Thanks for using MariaDB!

    提示:如没特殊要求,除设置root密码外,一路回车即可


    六.设置默认字符集

    请参看MariaDB编码问题

    因为是二进制安装,所以字符集在官方release的时候就指定了,如

    +--------------------------+---------------------------------------------------+

    | Variable_name            | Value                                             |

    +--------------------------+---------------------------------------------------+

    | character_set_client     | utf8                                              |

    | character_set_connection | utf8                                              |

    | character_set_database   | latin1                                            |

    | character_set_filesystem | binary                                            |

    | character_set_results    | utf8                                              |

    | character_set_server     | latin1                                            |

    | character_set_system     | utf8                                              |

    | character_sets_dir       | /opt/mariadb-10.1.10-linux-x86_64/share/charsets/ |

     

    +--------------------------+---------------------------------------------------+

    为了更好的通用性,生产更多用的是utf8,所以需要

    修主配置文件/etc/my.cnf

    [mysqld]

    init_connect = 'SET collation_connection = utf8_general_ci'

    init_connect = 'SET NAMES utf8'

    character_set_server = utf8

    collation_server = utf8_general_ci

    [mysqld_safe]

    init_connect = 'SET collation_connection = utf8_general_ci'

    init_connect = 'SET NAMES utf8'

    character_set_server = utf8

    collation_server = utf8_general_ci

    改完后重启MariaDB

    root@jlive:~#/etc/init.d/mysql restart

    Restarting mysql (via systemctl):                          [  确定  ]



    MariaDB [(none)]> SHOW VARIABLES LIKE 'character_%';

    +--------------------------+---------------------------------------------------+

    | Variable_name            | Value                                             |

    +--------------------------+---------------------------------------------------+

    | character_set_client     | utf8                                              |

    | character_set_connection | utf8                                              |

    | character_set_database   | utf8                                              |

    | character_set_filesystem | binary                                            |

    | character_set_results    | utf8                                              |

    | character_set_server     | utf8                                              |

    | character_set_system     | utf8                                              |

    | character_sets_dir       | /opt/mariadb-10.1.10-linux-x86_64/share/charsets/ |

    +--------------------------+---------------------------------------------------+

    8 rows in set (0.00 sec)


    MariaDB [(none)]> SHOW VARIABLES LIKE 'collation%';

    +----------------------+-----------------+

    | Variable_name        | Value           |

    +----------------------+-----------------+

    | collation_connection | utf8_general_ci |

    | collation_database   | utf8_general_ci |

    | collation_server     | utf8_general_ci |

    +----------------------+-----------------+

     

    3 rows in set (0.01 sec)



    七.测试

    [root@slave2 ~]# mysql -uroot -p

    Enter password: 

    Welcome to the MariaDB monitor.  Commands end with ; or g.

    Your MariaDB connection id is 13

    Server version: 10.1.10-MariaDB-log MariaDB Server


    Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.


    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.


    MariaDB [(none)]> show databases;

    +--------------------+

    | Database           |

    +--------------------+

    | information_schema |

    | mysql              |

    | performance_schema |

    +--------------------+

    3 rows in set (0.01 sec)


    MariaDB [(none)]> show engines;

    +--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+

    | Engine             | Support | Comment                                                                                          | Transactions | XA   | Savepoints |

    +--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+

    | MRG_MyISAM         | YES     | Collection of identical MyISAM tables                                                            | NO           | NO   | NO         |

    | CSV                | YES     | CSV storage engine                                                                               | NO           | NO   | NO         |

    | Aria               | YES     | Crash-safe tables with MyISAM heritage                                                           | NO           | NO   | NO         |

    | MyISAM             | YES     | MyISAM storage engine                                                                            | NO           | NO   | NO         |

    | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                                        | NO           | NO   | NO         |

    | InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, foreign keys and encryption for tables | YES          | YES  | YES        |

    | SEQUENCE           | YES     | Generated tables filled with sequential values                                                   | YES          | NO   | YES        |

    | PERFORMANCE_SCHEMA | YES     | Performance Schema                                                                               | NO           | NO   | NO         |

    +--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+

    8 rows in set (0.00 sec)


    MariaDB [(none)]> quit

     

    Bye

  • 相关阅读:
    Codeforces 1322B
    面向对象案例
    0428面向对象2.0
    0427 面向对象初识
    0427数组相关思想
    0426数组操作
    Eclipse使用技巧
    数组汇总0426
    0424数组练习
    数组习题练习0424
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814238.html
Copyright © 2011-2022 走看看