MariaBD安装配置

官方地址:https://mariadb.com/docs/server/deploy/topologies/single-node/community-server-10-5/

YUM安装:

  1、下载用到 wget 工具;

    yum install wget

  2、下载 MariaDB repo 的安装文件;默认下载到当前文件夹

    wget https://r.mariadb.com/downloads/mariadb_repo_setup

  3、特征码校验(可跳过该步骤);

    echo "ad125f01bada12a1ba2f9986a21c59d2cccbe8d584e7f55079ecbeb7f43a4da4 mariadb_repo_setup" | sha256sum -c -

  4、安装 MariaDB repo;

    chmod +x mariadb_repo_setup && ./mariadb_repo_setup --mariadb-server-version="mariadb-10.5"

  5、安装server以及相关的工具包;

    yum install MariaDB-server MariaDB-backup

安装完成。

  启动:

    systemctl start mysqld

  设置开机自启:

    systemctl enable mysqld

执行安全初始化程序:

  mysql_secure_installation

配置说明:

  /etc/my.cnf 用来声明包含 /etc/my.cnf.d/ 下的所有配置文件:

    /etc/my.cnf.d/client.cnf

    /etc/my.cnf.d/mysql-clients.cnf

    /etc/my.cnf.d/server.cnf

 server.cnf:

  [galera]

    # 跳过主机名解析,避免对主机名解析造成响应慢

    skip_name_resolve=on

    innodb_file_per_table = on

    # 修改数据的存储目录

    datadir = /var/mysql_data

调整数据的存放目录:

    配置文件:server.cnf

    参数:datadir = /var/mysql_data

    注意事项: /var/mysql_data 必须事先存在,将 /var/lib/mysql/ 下的所有文件都必须拷贝到  /var/mysql_data 中,同时注意文件的权限,建议使用 cp -ar 进行拷贝,将  /var/mysql_data  的属主和属组改为 mysql;保留  /var/lib/mysql/  mariadb在运行的时候会用到该目录,尽量不要删除;

 

登录:

  MariaDB在安装之后,系统默认创建 root@localhost 和 mysql@localhost 两个用户,是不需要密码便可登录的。

设置密码:  

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT PASSWORD('root');
+-------------------------------------------+
| PASSWORD('root')                          |
+-------------------------------------------+
| *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-------------------------------------------+
1 row in set (0.000 sec)

MariaDB [mysql]> ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B';
Query OK, 0 rows affected (0.000 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

  

二进制安装:

  https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/

 

  

 

posted @ 2023-05-01 09:49  青灯浊酒  阅读(72)  评论(0编辑  收藏  举报