当前位置: 首页>数据库>正文

mariaDB 国内下载地址 mariadb10.3安装

问题

centos直接安装mariadb会遇到众多问题。如果直接安装mysql, 由于oracle官方维护不够给力,使用起来有一定的风险,所以必须要安装mariadb。如果用yum安装(在阿里云亲测),由于网络不好,下载安装包的过程中,总是容易中断。如果用源码安装,先要求装gnutls, gnutls又依赖nettle,但是nettle即使版本是按gnutls要求安装的,仍然会报: Libnettle 3.1 was not found.  的问题

规划:

日志路径:/home/datum/data/logs/mariadb

数据库表数据路径: /home/datum/data/appdata/maria_data/dbdata

sock路径: /home/datum/data/appdata/maria_data/sock/

给相关的所有文件夹递归的赋权限: chmod -R 777 /home/datum/data





 安装操作系统底层依赖
 yum -y install lrzsz unzip lsof rsync cmake  gcc gcc-c++  autoconf automake zlib*  libxml* \
 ncurses ncurses-devel libtool  libtool-ltdl-devel* make  bison bison-devel  \
 openssl-devel libevent-devel \
 libaio libaio-devel pam-devel boost boost-devel valgrind-devel \
 libnl-devel popt-devel popt-static bzr




 yum -y install pcre-devel*  boost-devel   check-devel  boost-* nmap-* \
 nc-* openssl*




 下载安装文件
 查看可下载的galera文件:  http://galeracluster.com/downloads/
 查看可下载的mariadb文件: http://yum.mariadb.org/10.2/centos6-amd64/rpms/ 
 
 
 
如果galera用yum安装不成功,到 http://releases.galeracluster.com/galera-3/centos/6/x86_64/ 中查看合适的文件,并下载: wget http://releases.galeracluster.com/galera-3/centos/6/x86_64/galera-3-25.3.23-2.el6.x86_64.rpm
安装: rpm -ivh galera-3-25.3.23-2.el6.x86_64.rpm
 先进入 https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.2.6/yum/centos6-amd64/rpms/  选择要安装的具体文件
 再用命令下载安装文件:
 wget https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.2.6/yum/centos6-amd64/rpms/MariaDB-10.2.6-centos6-x86_64-client.rpm
 wget https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.2.6/yum/centos6-amd64/rpms/MariaDB-10.2.6-centos6-x86_64-server.rpm


 如果下载失败,进入官方库下载:  https://downloads.mariadb.org/mariadb/

 wget http://yum.mariadb.org/10.2/centos6-amd64/rpms/MariaDB-10.2.9-centos6-x86_64-common.rpm
 wget http://yum.mariadb.org/10.2/centos6-amd64/rpms/MariaDB-10.2.9-centos6-x86_64-compat.rpm
 wget http://yum.mariadb.org/10.2/centos6-amd64/rpms/MariaDB-10.2.9-centos6-x86_64-client.rpm
 wget http://yum.mariadb.org/10.2/centos6-amd64/rpms/MariaDB-10.2.9-centos6-x86_64-server.rpm


 如果不能下载,则查看是不是版本有修改,换成存在的版本文件即可。



 安装
 卸载老版,以免产生冲突:卸载老版,以免产生冲突 : yum remove mysql-libs
 安装所依赖的基础库: yum -y install galera perl perl-DBI
 安装commn,compat,命令: rpm -ivh MariaDB-10.2.9-centos6-x86_64-common.rpm MariaDB-10.2.9-centos6-x86_64-compat.rpm

 安装devel,命令:  rpm -ivh MariaDB-10.2.11-centos6-x86_64-devel.rpm 
 安装客户端: rpm -ivh MariaDB-10.2.9-centos6-x86_64-client.rpm 
 再安装server,命令: rpm -ivh MariaDB-10.2.6-centos6-x86_64-server.rpm


 注意:  commn,compat要一起安装,否则会报以下的错误:


 # rpm -ivh MariaDB-10.2.9-centos6-x86_64-compat.rpm 
 warning: MariaDB-10.2.9-centos6-x86_64-compat.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
 error: Failed dependencies:
 MariaDB-common is needed by MariaDB-compat-10.2.9-1.el6.x86_64
 # rpm -ivh MariaDB-10.2.9-centos6-x86_64-common.rpm
 warning: MariaDB-10.2.9-centos6-x86_64-common.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
 error: Failed dependencies:
 MariaDB-compat is needed by MariaDB-common-10.2.9-1.el6.x86_64




 数据库配置
 配置数据库。先看有没有文件/etc/my.cnf  ,如果没有, 执行 cp /usr/share/mysql/my-large.cnf /etc/my.cnf  先将配置文件拷到默认位置,然后再修改里面的内容。

 配置内容:
 # The following options will be passed to all MariaDB clients
 [client] #password=your_password
 port=3306
 socket=/home/datum/data/appdata/maria_data/sock/mysql.sock


 # Here follows entries for some specific programs

 # The MariaDB server
 [mysqld]
 port=3306character_set_server=utf8
 datadir=/home/datum/data/appdata/maria_data/dbdata
 socket=/home/datum/data/appdata/maria_data/sock/mysql.sock
 skip-external-locking
 key_buffer_size = 256M
 max_allowed_packet = 1M
 table_open_cache = 256
 sort_buffer_size = 1M
 read_buffer_size = 1M
 read_rnd_buffer_size = 4M
 myisam_sort_buffer_size = 64M
 thread_cache_size = 8
 query_cache_size= 128M# Replication Master Server (default)
 # binary logging is required for replication
 log-bin=mysql-bin


 # binary logging format - mixed recommended
 binlog_format=mixed


 # required unique id between 1 and 2^32 - 1
 # defaults to 1 if master-host is not set
 # but will not function as a master if omitted
 server_id=1


 log-error=/home/datum/data/logs/mariadb/mysql.log
 slow-query-log = 1
 slow-query-log-file =/home/datum/data/logs/mariadb/mysql-slow.log
 long_query_time =5
 wait_timeout=2147483
 interactive_timeout=2147483


 #10s per transaction
 innodb_lock_wait_timeout=10


 #mysql 事件计划开启
 event_scheduler=1


 # from net  http://www.tuicool.com/articles/a6jeiu   http://www.jb51.net/article/58537.htm
 # 启用 InnoDB 的每张表一个数据文件设置
 innodb_file_per_table=1
 # 配置 MySQL 的线程缓存数量
 thread_cache_size =32
 # 配置 MySQL 的查询缓存容量。验证: show status like '%Qcache%';
 query_cache_type=1
 # query_cache_limit = 256K
 # query_cache_min_res_unit = 2k
 query_cache_size=128M


 [mysqldump]
 quick
 max_allowed_packet = 16M





 [myisamchk]
 key_buffer_size = 128M
 sort_buffer_size = 128M
 read_buffer = 2M
 write_buffer = 2M


 [mysqlhotcopy]
 interactive-timeout


 设置相关文件夹的权限:  chown -R mysql:mysql /home/datum/data/logs/mariadb
 chown -R mysql:mysql /home/datum/data/appdata/maria_data
 chmod -R 777 /home/datum/data/appdata/maria_data
 chmod -R 777 /home/datum/data/logs/mariadb


 执行mariadb初始化命令:


 cd /etc/my.cnf.d/ 
 
mysql_install_db --defaults-file=/etc/my.cnf --datadir=/home/datum/data/appdata/maria_data/dbdata/ --user=mysql 
 
有些mysql的命令是访问的是其它目录的mysql.sock,做一下链接(此处用的是软链接):
ln -s /home/datum/data/appdata/maria_data/sock/mysql.sock /var/lib/mysql/mysql.sock

 启动mariadb(mysql):   service mysql start
 mariadb重置密码命令:mysqladmin -u root password "123456"如果报错,则修改mysql文件: vim /etc/init.d/mysql  找到  bindir/mysqld_safe,在后面添加 “ --user=root”如下:
307     then
 308       # Give extra arguments to mysqld with the my.cnf file. This script
 309       # may be overwritten at next upgrade.
 310       $bindir/mysqld_safe --user=root --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
 311       wait_for_ready; return_value=$?
 312 
 313       # Make lock for RedHat / SuSE
 314       if test -w "$lockdir"
 315       then
 316         touch "$lock_file_path"

 允许远程登录: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;  flush privileges;
 其中,123456为root的密码。root密码设置完后,必须要重启mysql才能生效


 重启mariadb(mysql):   service mysql restart


 mariadb用户名密码登录命令:  mysql -uroot -p123456
 允许远程登录: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;  flush privileges;
 其中,123456为root的密码。在实际的命令中,要把密码修改掉,不然登录不上


 查看数据库: show databases;
 切换数据库: use mysql;
 展示所有表: show tables;
 卸载老版,以免产生冲突

https://www.xamrdz.com/database/6u71961125.html

相关文章: