欢迎投稿

今日深度:

MariaDB 10.2.15 二进制安装,mariadb10.2.15

MariaDB 10.2.15 二进制安装,mariadb10.2.15


1.规划:
数据文件存储位置 /data/mysql/data
日志文件存储位置 /home/logs/mysql
binlog文件存储位置 /data/mysql
2.创建目录和授权:
mkdir -p /data/mysql/data
mkdir -p /home/logs/mysql
useradd mysql
chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /home/logs
chmod -R 775 /data/mysql
chmod -R 775 /home/log
3.文件下载:
wget https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.15/bintar-linux-systemd-x86_64/mariadb-10.2.15-linux-systemd-x86_64.tar.gz

4.解压文件:

#tar -xzvf mariadb-10.2.15-linux-systemd-x86_64.tar.gz -C /usr/local
#mv /usr/local/mariadb-10.2.15-linux-systemd-x86_64 /usr/local/mysql

 

4.1 设置mysql的配置文件:
# cat /etc/my.cnf 
[mysqld]
user                            = mysql
datadir                         = /data/mysql/data
port                            = 3306
pid-file                        = /tmp/mysql.pid
socket                          = /tmp/mysql.sock
server-id                       = 2
default-storage-engine         =InnoDB
character-set-client-handshake = FALSE
character-set-server           = utf8mb4
collation-server               = utf8mb4_unicode_ci
init_connect                   ='SET NAMES utf8mb4'
performance-schema-instrument='memory/%=COUNTED'
interactive_timeout            = 172800
wait_timeout                   = 172800
tmp-table-size                 = 8M
max-heap-table-size            = 4M
query-cache-type               = 0
query-cache-size               = 64M
max-connections                = 80
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 10
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 256M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 3G
log-error                      = /home/logs/mysql/mysql_error.log
slow-query-log                 = 1
slow-query-log-file            = /home/logs/mysql/mysql_slow.log
long_query_time                = 0.2
min_examined_row_limit         = 100
max-allowed-packet             = 16M
max-connect-errors             = 1000000
#skip-name-resolve
sql-mode                       =ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sysdate-is-now                 = 1
innodb-strict-mode             = 1
sort_buffer_size              = 2M
join_buffer_size              = 2M
key_buffer_size               = 64M
read_buffer_size              = 512K
read_rnd_buffer_size          = 256K
binlog_cache_size             = 2M
thread_stack                  = 256K
bulk_insert_buffer_size       = 64M
lower_case_table_names        = 1
relay-log                     =/home/logs/mysql/mysql_relay.log
relay_log_recovery            =1
slave-net-timeout             =60
relay_log_purge               =0
sync_binlog                   = 1
log-bin                       =/data/mysql/mysql_bin.log
binlog_format                 =ROW
expire-logs-days              =2
relay_log_recovery             = 1
slave_skip_errors              = ddl_exist_errors
explicit_defaults_for_timestamp =true

 

5.数据初始化:
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql               
Installing MariaDB/MySQL system tables in '/data/mysql/data' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/local/mysql/bin/mysqladmin' -u root password 'new-password'
'/usr/local/mysql/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
'/usr/local/mysql/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr/local/mysql' ; /usr/local/mysql/bin/mysqld_safe --datadir='/data/mysql/data'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mysql/mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
6.设置启动文件:
# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql
7.启动数据库:
# /etc/init.d/mysql start
Starting mysql (via systemctl):                            [  OK  ]
8.登录数据库:(初次登录root用户无密码)
# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.15-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, 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 |
| test               |
+--------------------+
4 rows in set (0.00 sec)
9.设置远程用户可以登录:
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by 'xxxxxx' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
10.为了方便以后使用需要设置环境变量:
# cat /etc/profile.d/mysql.sh 
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
#source /etc/profile.d/mysql.sh 

 

 

 

www.htsjk.Com true http://www.htsjk.com/mariadb/32151.html NewsArticle MariaDB 10.2.15 二进制安装,mariadb10.2.15 1.规划:数据文件存储位置 /data/mysql/data日志文件存储位置 /home/logs/mysqlbinlog文件存储位置 /data/mysql2.创建目录和授权:mkdir -p /data/mysql/datamkdir -p /h...
相关文章
    暂无相关文章
评论暂时关闭