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 or MySQL on Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you how to install MariaDB or MySQL on Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Both MariaDB and MySQL are open source databases that use SQL and share the same initial code base. MariaDB is an alternative to MySQL, and you can use the same command (mysql) to interact with MySQL and MariaDB databases. Therefore, this paper applies to both MariaDB and MySQL.

Install MariaDB

You can install MariaDB using the package manager of your Linux distribution. On most distributions, MariaDB is divided into server packages and client packages. The server package provides a database "engine", the part of the MariaDB that runs in the background (usually on a physical server), which listens for data input or data output requests. The client package provides mysql commands that you can use to communicate with the server.

On RHEL, Fedora, CentOS, or similar distributions:

$sudo dnf install mariadb mariadb-server

On Debian, Ubuntu, Elementary, or similar distributions:

$sudo apt install mariadb-client mariadb-server

Other operating systems may package MariaDB in different packaging systems, so you may need to search your software repository to find out how maintainers of your distribution provide it.

Start MariaDB

Because MariaDB is designed partly as a database server, it can be run on one computer and managed from another. As long as you can access the computer on which it is running, you can use the mysql command to manage the database. At the time of this writing, I ran MariaDB on my local computer, but you can also interact with MariaDB databases hosted on remote systems.

Before starting MariaDB, you must create an initial database. When initializing its file structure, you should define the users you want MariaDB to use. By default, MariaDB uses the current user, but you may want it to use a dedicated user account. Your package manager may have configured a system user and group for you. Use grep to find out if there is a mysql group:

$grep mysql / etc/groupmysql:x:27:

You can also look for this specific user in / etc/passwd, but usually there will be users if there is a group. If you don't have dedicated mysql users and groups, you can look for an obvious alternative (such as mariadb) in / etc/group. If not, please read your distribution documentation to see how MariaDB works.

Suppose your installation uses mysql to initialize the database environment:

$sudo mysql_install_db-- user=mysqlInstalling MariaDB/MySQL system tables in'/ var/lib/mysql'...OK [...]

The result of this step shows the next tasks you must perform to configure MariaDB:

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER! To do so, start the server, then issue the following commands:'/ usr/bin/mysqladmin'-u root password' new-password''/usr/bin/mysqladmin'-u root-h $(hostname) password' new-password' Alternatively you can run:'/usr/bin/mysql_secure_installation' which will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.

Start MariaDB using your distribution's initialization system:

$sudo systemctl start mariadb

Enable the MariaDB server at startup:

$sudo systemctl enable-now mariadb

Now that you have a MariaDB server, set a password for it:

Mysqladmin-u root password 'myreallysecurepassphrase'mysqladmin-u root-h $(hostname) password' myreallysecurepassphrase'

Finally, if you plan to use it on a production server, run the mysql_secure_installation command before going online.

The above is all the contents of the article "how to install MariaDB or MySQL on Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report