Linux下MariaDB 10安装与配置指南
首先把安装包下载到本地,然后解压到/usr/local目录:
tar -zxvf mariadb-10.5.0-linux-systemd-x86_64.tar.gz -C /usr/local/
下载mysql
从阿里云下载mariadb: https://mirrors.aliyun.com/mariadb/
上传至Linux主机
解压mysql
tar -zxvf mariadb-10.11.15-linux-systemd-x86_64.tar.gz -C /usr/local
tar -zxvf mariadb-10.11.15-linux-systemd-x86_64.tar.gz -C /usr/local mv /usr/local/mariadb-* /usr/local/mysql chown -R root:root /usr/local/mysql准备安装环境
添加用户组和用户:
mkdir /home/mysql groupadd mysql && useradd -r -g mysql mysql -d /home/mysql chown mysql:mysql /home/mysqluseradd -s /sbin/nologin -d /opt/lnmp/bin/mariadb mysql
创建数据目录并赋予权限:
mkdir -p /data/mysql chown mysql:mysql -R /data/mysql修改配置文件:
cat << EOF >/etc/my.cnf [mysqld] bind-address=0.0.0.0 port=3306 user=mysql basedir=/usr/local/mysql datadir=/data/mysql socket=/tmp/mysql.sock log-error=/data/mysql/mysql.err pid-file=/data/mysql/mysql.pid #character config character_set_server=utf8mb4 explicit_defaults_for_timestamp=true server_id = 1 #log_bin = /var/log/mysql/mysql-bin.log EOF初始化mariadb
将解压后的文件移动到/usr/local
/usr/local/mysql/scripts/mariadb-install-db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysqlInstalling MariaDB/MySQL system tables in '/data/mariadb' ... OK To start mariadbd at boot time you have to copy support-files/mariadb.service to the right place for your system Two all-privilege accounts were created. One is root@localhost, it has no password, but you need to be system 'root' user to connect. Use, for example, sudo mariadb The second is mysql@localhost, it has no password either, but you need to be the system 'mysql' user to connect. After connecting you can set the password, if you would need to be able to connect as any of these users with a password and without sudo See the MariaDB Knowledgebase at https://mariadb.com/kb You can start the MariaDB daemon with: cd '/usr/local/mariadb' ; /usr/local/mysql/bin/mariadbd-safe --datadir='/data/msyql' You can test the MariaDB daemon with mysql-test-run.pl cd '/usr/local/mariadb/mysql-test' ; perl mariadb-test-run.pl Please report any problems at https://mariadb.org/jira The latest information about MariaDB is available at https://mariadb.org/. Consider joining MariaDB's strong and vibrant community: https://mariadb.org/get-involved/