MariaDB数据库治理系统是MySQL的一个分支,主要由开源社区在维护,接纳GPL授权允许 MariaDB的目的是完全兼容MySQL,包罗API和命令行,使之能轻松成为MySQL的取代品。在存储引擎方面,使用XtraDB来取代MySQL的InnoDB


实验环境

centos6.9_x64  192.168.10.15


实验软件

mariadb-10.1.22.tar.gz


软件安装

yum remove -y mysql

yum install -y libevent libevent-devel curses curses-devel openssl-devel openssl lrzsz gcc make cmake 

yum groupinstall -y Development Tools


groupadd mysql && useradd -r -g mysql mysql

mkdir -pv /usr/local/mariadb && mkdir -pv /usr/local/mariadb/data


tar zxvf /root/mariadb-10.1.22.tar.gz

cd /root/mariadb-10.1.22

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \

   -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

   -DMYSQL_DATADIR=/usr/local/data/mariadb \

   -DSYSCONFDIR=/etc \

   -DMYSQL_USER=mysql \

   -DMYSQL_TCP_PORT=3306 \

   -DWITH_XTRADB_STORAGE_ENGINE=1 \

   -DWITH_INNOBASE_STORAGE_ENGINE=1 \

   -DWITH_PARTITION_STORAGE_ENGINE=1 \

   -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

   -DWITH_MYISAM_STORAGE_ENGINE=1 \

   -DWITH_READLINE=1 \

   -DENABLED_LOCAL_INFILE=1 \

   -DWITH_EXTRA_CHARSETS=1 \

   -DDEFAULT_CHARSET=utf8 \

   -DDEFAULT_COLLATION=utf8_general_ci \

   -DEXTRA_CHARSETS=all \

   -DWITH_BIG_TABLES=1 \

   -DWITH_DEBUG=0 \

   -DCURSES_LIBRARY=/usr/lib/libncurses.so \

   -DCURSES_INCLUDE_PATH=/usr/include

make -j6 && make  install


cp -pv /root/mariadb-10.1.22/support-files/my-small.cnf /etc/my.cnf

cp -pv /root/mariadb-10.1.22/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/rc.d/init.d/mysqld && chkconfig --level 35 mysql on

touch /usr/local/mariadb/data/mariadb-error.log

touch /usr/local/mariadb/data/mariadb-slow.log

chown -R mysql:mysql /usr/local/mariadb/


cp -pv /etc/my.cnf  /etc/my.cnf.bak

cat /etc/my.cnf

[mysqld]

basedir = /usr/local/mariadb

datadir = /usr/local/data/mariadb

character-set-server = utf8

collation-server = utf8_general_ci

user = mysql

port = 3306

default_storage_engine = InnoDB

innodb_file_per_table = 1

server_id = 1

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 7

bind-address = 0.0.0.0


# name-resolve

skip-name-resolve

skip-host-cache


#lower_case_table_names = 1

ft_min_word_len = 1

query_cache_size = 64M

query_cache_type = 1


skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M


# LOG

log_error = /usr/local/mariadb/data/mariadb-error.log

long_query_time = 1

slow_query_log

slow_query_log_file = /usr/local/mariadb/data/mariadb-slow.log


# Oher

#max_connections = 1000

open_files_limit = 65535


[client]

port = 3306


/usr/local/mariadb/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/usr/local/data/mariadb &

cp -pv /etc/profile /etc/profile.bak

echo 'export PATH=$PATH:/usr/local/mariadb/bin' >> /etc/profile && source  /etc/profile

tail -1 /etc/profile

export PATH=$PATH:/usr/local/mariadb/bin

service mysqld restart


netstat -tuplna | grep 3306

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

ps -ef | grep 3306

mysql     32752  32576  0 22:50 pts/0    00:00:00 /usr/local/mariadb/bin/mysqld --basedir=/usr/local/mariadb --datadir=/usr/local/data/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/usr/local/mariadb/data/mariadb-error.log --open-files-limit=65535 --pid-file=/usr/local/data/mariadb/centos6.pid --port=3306

root      32790   7024  0 22:51 pts/0    00:00:00 grep 3306


mysql -uroot -p数据库密码

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";  设置远程接见权限

MariaDB [mysql]> update user set Password = password('123.com') where User='root'; /mysqladmin -uroot  password 数据库密码  修改root密码 

MariaDB [(none)]> flush privileges;