一 Mariadb数据库安装
1 源码二进制安装
1.1.1 准备所需用户
[root@mysql-master ~]# useradd -r mysql -s /sbin/nologin [root@mysql-master ~]# id mysql uid=996(mysql) gid=994(mysql) 组=994(mysql)
1.1.2 解压创建相应目录
[root@mysql-master ~]# tar xf mariadb-10.2.22-linux-x86_64.tar.gz -C /usr/local/ [root@mysql-master ~]# cd /usr/local/ [root@mysql-master local]# ln -s mariadb-10.2.22-linux-x86_64/ mysql [root@mysql-master local]# chown -R mysql.mysql mysql/ [root@mysql-master local]# cd mysql/bin/ [root@mysql-master bin]# pwd /usr/local/mysql/bin [root@mysql-master bin]# echo ‘PATH=/usr/local/mysql/bin:$PATH‘ > /etc/profile.d/mysql.sh [root@mysql-master bin]# . /etc/profile.d/mysql.sh [root@mysql-master bin]# mkdir /data/mysqldb -p [root@mysql-master bin]# chown -R mysql.mysql /data/mysqldb/ [root@mysql-master bin]# chmod 770 /data/mysqldb/
1.1.3 初始化数据库
[root@mysql-master mysql]# scripts/mysql_install_db --datadir=/data/mysqldb --user=mysql Installing MariaDB/MySQL system tables in ‘/data/mysqldb‘ ... 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: ‘./bin/mysqladmin‘ -u root password ‘new-password‘ ‘./bin/mysqladmin‘ -u root -h mysql-master password ‘new-password‘ Alternatively you can run: ‘./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 ‘.‘ ; ./bin/mysqld_safe --datadir=‘/data/mysqldb‘ You can test the MariaDB daemon with mysql-test-run.pl cd ‘./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/
1.1.4 配置主配置文件,以及启动文件
# 拷贝模板文件 [root@mysql-master support-files]# pwd /usr/local/mysql/support-files [root@mysql-master support-files]# cp my-huge.cnf /etc/my.cnf cp:是否覆盖"/etc/my.cnf"? y # 修改数据库存储位置 [root@mysql-master support-files]# vim /etc/my.cnf [mysqld] datadir=/data/mysqldb # 拷贝启动文件 [root@mysql-master support-files]# cp mysql.server /etc/init.d/mysqld [root@mysql-master support-files]# chkconfig --add mysqld [root@mysql-master support-files]# chkconfig --list mysqld 0:关 1:关 2:开 3:开 4:.5:开 6:关 netconsole 0:关 1:关 2:关 3:关 4:.5:关 6:关 network 0:关 1:关 2:开 3:开 4:.5:开 6:关 # 启动服务 [root@mysql-master support-files]# service mysqld start Starting mysqld (via systemctl): [ 确定 ] [root@mysql-master support-files]# ls /data/mysqldb/aria_log.00000001 mysql aria_log_control mysql-bin.000001 ib_buffer_pool mysql-bin.index ibdata1 mysql-master.err ib_logfile0 mysql-master.pid ib_logfile1 performance_schema ibtmp1 test multi-master.info
1.1.5 初始化安全配置
[root@mysql-master support-files]# mysql_secure_installation
原文:https://www.cnblogs.com/yanshicheng/p/10403850.html