Second MySQL instance

  1. Create /etc/mysql/my-slave.cnf (minimal configuration)
    [client]
    port            = 3307
    socket          = /var/run/mysql/mysql-slave.sock
    default-character-set=utf8
    
    [mysqld]
    server-id               = 3
    port                    = 3307
    socket                  = /var/run/mysql/mysql-slave.sock
    pid-file                = /var/run/mysql/mysql-slave.pid
    datadir                 = /var/lib/mysql-slave
    #tmpdir                  = /var/lib/tmp
    #slave-load-tmpdir       = /var/lib/tmp
    general_log_file        = /var/lib/mysql-slave/mysql-slave.err
    log-error               = /var/lib/mysql-slave/mysql-slave.err
    slow_query_log_file     = /var/lib/mysql-slave/mysql-slave-slow.err
    character-set-server    = utf8
    collation-server        = utf8_unicode_ci
    
    skip-external-locking
    log-bin=mysql-bin
    read-only
    
    key_buffer = 16K
    max_allowed_packet = 16M
    thread_stack = 64K
    table_open_cache = 4
    sort_buffer_size = 64K
    read_buffer_size = 256K
    read_rnd_buffer_size = 256K
    net_buffer_length = 2K
    thread_stack = 64K
    
  2. Create data directory and init database
    mkdir /var/lib/mysql-slave
    chown -R mysql.mysql /var/lib/mysql-slave
    mysql_install_db --user=mysql --datadir=/var/lib/mysql-slave
  3. Run server
    mysqld_safe --defaults-file=/etc/mysql/my-slave.cnf --user=mysql &
  4. Set root access from LAN and password
    mysql --defaults-file=/etc/mysql/my-slave.cnf -e "SET PASSWORD=PASSWORD('newpassword'); \G CREATE USER root@'192.168.0.%' IDENTIFIED BY 'newpassword'; \G GRANT ALL PRIVILEGES ON *.* TO root@'192.168.0.%' WITH GRANT OPTION; \G"

© 2003-24 iNeta d.o.o. | Koroška cesta 31, SI-4000 Kranj | info@ineta.si | Pravno obvestilo
Powered by BravoCMS