Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MariaDB in Linux system

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to install MariaDB in the Linux system. I hope you will get something after reading this article. Let's discuss it together.

MariaDB database management system is a branch of MySQL and is mainly maintained by the open source community. The purpose of licensing MariaDB with GPL is to be fully compatible with MySQL, including API and the command line, making it an easy replacement for MySQL.

Preparation in advance

First of all, go to MariaDB official website to download the installation package, the home page is: https://mariadb.org/

Then click Download to enter the download page at https://downloads.mariadb.org/

Click the green button here to download the latest stable version 10.1.18 to go to the selection page:

Because it is compiled and installed here, we do not download the binary package of a certain system for the time being. Download the source package mariadb-10.1.18.tar.gz here, download it and upload it to the server.

Installation dependency

Before installing MariaDB, you need to install cmake first, and to ensure that there is no shortage of dependencies, use yum or rpm to install dependencies: readline-devel,zlib-devel,openssl-devel,libaio-devel and readline-devel depend on ncurses-devel. If you use yum, you will install the required dependencies automatically. The specific commands are as follows:

Yum-y install readline-develyum-y install zlib-develyum-y install openssl-develyum-y install libaio-devel

Here, book the installation directory of mysql as / usr/local/mysql and the data directory as / data1/mysql in advance. Here, you need to create users and directories, and grant mysql user permissions, as follows:

Groupadd-r mysqluseradd-g mysql-s / sbin/nologin mysqlmkdir / usr/local/mysqlmkdir-p / data1/mysqlchown-R mysql:mysql / data1/mysql/

Now you can start the installation, extract the installation package and go to the directory:

Tar-xvzf mariadb-10.1.18.tar.gzcd mariadb-10.1.18/ compilation and installation

Perform a compilation installation:

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data1/mysql-DSYSCONFDIR=/etc-DWITHOUT_TOKUDB=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STPRAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWIYH_READLINE=1-DWIYH_SSL=system-DVITH_ZLIB=system-DWITH_LOBWRAP=0-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci

Explain here:-DCMAKE_INSTALL_PREFIX is the specified installation location, here is / usr/local/mysql,-DMYSQL_DATADIR is the specified MySQL data directory, here is / data1/mysql, the installation directory and data directory can be customized,-DSYSCONFDIR is the directory where the specified configuration file is located, usually / etc, the specific configuration file is / etc/my.cnf,-DWITHOUT_TOKUDB=1 this parameter is generally set on Does not install the tokudb engine, tokudb is an open source storage engine in MySQL, which can manage a large amount of data and has some new features that Innodb does not have. The reason why it is not installed here is that the general computer does not have Percona Server by default, and loading tokudb also depends on jemalloc memory optimization, which is generally not used in development, so it is temporarily blocked. Otherwise, no dependency can be found in the system: an error such as CMake Error at storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake:179 (message) will occur, and then the following parameters are optional, either with or without. It is recommended to set the final encoding, so the compilation instructions can also be simplified as follows:

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data1/mysql-DSYSCONFDIR=/etc-DWITHOUT_TOKUDB=1-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci

Note: if there is an error in the execution, you can execute: rm-f CMakeCache.txt delete the compilation cache and let the instruction be executed again, otherwise every time the file is read, the correct modification of the command will also report an error

Cmake is fine, you can compile and install: make & & make install takes a long time, wait patiently

Execution is complete, that is, the installation is complete. Now execute cd / usr/local/mysql/ to enter the mysql installation directory and execute the following commands:

Chown-R mysql:mysql .scripts / mysql_install_db-- datadir=/data1/mysql-- user=mysqlchown-R root .cp support-files/mysql.server / etc/init.d/mysqld system configuration

You can then add mysqld to the system service:

Chkconfig-- add mysqld # add to system service chkconfig mysqld on # set boot self-startup

Now, if you start up, you may get an error because the log directory has not been established. The default is / var/log/mariadb/mariadb.log, which can also be modified later. Execute: mkdir/var/log/mariadb to establish the log directory now, and then execute: / etc/init.d/mysqld start or systemctl start mysqld.service can start the mysql service.

After starting the service, you cannot immediately enter the mysql shell interface, because when you compiled, the local socket was: / tmp/mysql.sock, but the location configured in / etc/my.cnf is: / var/lib/mysql/mysql.sock. Now execute the command: ln-s / var/lib/mysql/mysql.sock / tmp/mysql.sock to establish a soft link

To make it easier to add the mysql directory to the environment variables, you can now execute. / bin/mysql directly into the MariaDB interactive interface, and the default root user password is empty:

After reading this article, I believe you have some understanding of "how to install MariaDB in Linux system". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report