You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/databases/mariadb/how-to-install-mariadb-on-debian-9/index.md
+41-31Lines changed: 41 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
2
-
slug: how-to-install-mariadb-on-debian-9
3
-
title: "Installing MariaDB on Debian 9"
4
-
title_meta: "How to Install MariaDB on Debian 9"
5
-
description: "This guide shows how to install and configure the MariaDB server on Debian 9."
6
-
og_description: "MariaDB is a robust, scalable and reliable SQL Server that can serve as a drop-in replacement for MySQL. This guide shows how to install and configure it on Debian 9."
2
+
slug: how-to-install-mariadb-on-debian-12
3
+
title: "Installing MariaDB on Debian 12"
4
+
title_meta: "How to Install MariaDB on Debian 12"
5
+
description: "This guide shows how to install and configure the MariaDB server on Debian 12."
6
+
og_description: "MariaDB is a robust, scalable and reliable SQL Server that can serve as a drop-in replacement for MySQL. This guide shows how to install and configure it on Debian 12 (Bookworm)."
MariaDB is a fork of the popular cross-platform MySQL database management system and is considered a full [drop-in replacement](https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-features/) for MySQL. MariaDB was created by one of MySQL's original developers in 2009 after MySQL was acquired by Oracle during the Sun Microsystems merger. Today MariaDB is maintained and developed by the [MariaDB Foundation](https://mariadb.org/en/foundation/) and community contributors with the intention of it remaining GNU GPL software.
28
28
29
-
{{< note >}}
29
+
**Note:**
30
30
This guide is written for a non-root user. Commands that require elevated privileges are prefixed with `sudo`. If you're not familiar with the `sudo` command, you can check our [Users and Groups](/docs/guides/linux-users-and-groups/) guide.
31
-
{{< /note >}}
32
31
33
32
## Before You Begin
34
33
35
-
1. If you have not already done so, create a Linode account and Compute Instance. See our [Getting Started with Linode](/docs/products/platform/get-started/) and [Creating a Compute Instance](/docs/products/compute/compute-instances/guides/create/) guides.
34
+
1. If you have not already done so, create a Linode account and Compute Instance. See our [Get Started](/docs/products/platform/get-started/)with Linode and [Creating a Linode (Compute Instance)](/docs/products/compute/compute-instances/guides/create/) guides.
36
35
37
-
1. Follow our [Setting Up and Securing a Compute Instance](/docs/products/compute/compute-instances/guides/set-up-and-secure/) guide to update your system and configure your hostname. You may also wish to set the timezone, create a limited user account, and harden SSH access.
36
+
1. Follow our [Setting Up and Securing a Compute Instance](/docs/products/compute/compute-instances/guides/set-up-and-secure/) guide to update your system and configure your hostname. You can also to set the timezone, create a limited user account, and harden SSH access.
38
37
39
38
To check your hostname run:
40
39
@@ -49,31 +48,32 @@ Install MariaDB using the package manager.
49
48
50
49
sudo apt install mariadb-server
51
50
52
-
MariaDB will bind to localhost (127.0.0.1) by default. For information on connecting to a remote database using SSH, see our [MySQL remote access guide](/docs/guides/create-an-ssh-tunnel-for-mysql-remote-access/), which also applies to MariaDB.
51
+
MariaDB will bind to localhost (127.0.0.1) by default. For information on connecting to a remote database using SSH, see our [MySQL remote access](/docs/guides/create-an-ssh-tunnel-for-mysql-remote-access/) guide, which also applies to MariaDB.
53
52
54
-
{{< note >}}
55
-
Allowing unrestricted access to MariaDB on a public IP not advised but you may change the address it listens on by modifying the `bind-address` parameter in `/etc/my.cnf`. If you decide to bind MariaDB to your public IP, you should implement firewall rules that only allow connections from specific IP addresses.
56
-
{{< /note >}}
53
+
**Note:**
54
+
Allowing unrestricted access to MariaDB on a public IP is not advised. However, you can change the address it listens on by modifying the `bind-address` parameter in `/etc/mysql/mariahdb.conf.d/50-server.cnf`. If you decide to bind MariaDB to your public IP address, you should implement firewall rules that restrict access to specific IP addresses.
57
55
58
56
### MariaDB Client
59
57
60
-
The standard tool for interacting with MariaDB is the `mariadb` client, which installs with the `mariadb-server` package. The MariaDB client is used through a terminal using the `mysql` command.
58
+
The standard tool for interacting with MariaDB is the `mariadb` client, which is installed alongside the `mariadb-server` package. You can access the MariaDB client in the terminal using the `mysql` command.
61
59
62
60
### Root Login
63
61
64
-
1.Log into MariaDB as the root user:
62
+
Log into MariaDB as the root user:
65
63
66
64
sudo mysql -u root -p
67
65
68
-
1. When prompted for login credentials, hit enter. By default MariaDB will authenticate you via the **unix_socket plugin** and credentials are not required.
66
+
67
+
**Note:**
68
+
On Debian 12, MariaDB uses the `unix_socket` plugin by default. This means that if you're logged into the system as a user with root privileges, you can press **Enter** at the password prompt and still gain access--no password is required.
69
69
70
70
You'll then be presented with a welcome header and the MariaDB prompt as shown below:
71
71
72
72
{{< output >}}
73
73
MariaDB [(none)]>
74
74
{{</ output >}}
75
75
76
-
1.To generate a list of commands for the MariaDB prompt, enter`\h`. You'll then see:
76
+
To view a list of available commands, type`\h` at the prompt. You then see:
77
77
78
78
{{< output >}}
79
79
General information about MariaDB can be found at
@@ -113,25 +113,33 @@ MariaDB [(none)]>
113
113
114
114
### Securing the Installation
115
115
116
-
1. After accessing MariaDB as the root user of your database, enable the **mysql_native_password**
117
-
plugin to enable root password authentication:
116
+
After accessing MariaDB as the root user, you can switch from socket-based authentication to password-based authentication by enabling the `mysql_native_password` plugin:
118
117
119
118
USE mysql;
120
119
UPDATE user SET plugin='mysql_native_password' WHERE user='root';
121
120
FLUSH PRIVILEGES;
122
121
exit;
123
122
124
-
1. Run the `mysql_secure_installation` script to address several security concerns in a default MariaDB installation:
123
+
**New in MariaDB 10.11 on Debian 12:**
124
+
The `mysql_secure_installation` script now offers the option to *set a root password,** which automatically switches the authentication method from `unix_socket` to `mysql_native_password`. This is a change from earlier versions, where socket-based authentication was the default and required manual reconfiguration.
125
+
126
+
Next, run the `mysql_secure_installation` script to address several security concerns in a default MariaDB installation:
125
127
126
128
sudo mysql_secure_installation
127
129
128
-
You will be given the choice to change the MariaDB root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases. It is recommended that you answer `yes` to these options. You can read more about the script in the [MariaDB Knowledge Base](https://mariadb.com/kb/en/mariadb/mysql_secure_installation/).
130
+
This script will guide you through several options, including:
131
+
- Setting a root password (if you haven't already).
132
+
- Removing anonymous user accounts.
133
+
- Disabling remote root logins
134
+
- Removing the test database
135
+
136
+
It's recommended that you answer `yes` to these prompts for a more secure setup (to harden your MariaDB installation against unauthorized access). You can read more about the script in the [MariaDB Knowledge Base](https://mariadb.com/kb/en/mariadb/mysql_secure_installation/).
129
137
130
138
## Using MariaDB
131
139
132
140
### Create a New MariaDB User and Database
133
141
134
-
1.Login to the database again. This time, if you set a password above, enter it at the prompt.
142
+
1.Log in to the database again. When you're prompted to log in to MariaDB again, you should enter the password only if you previously set one during an earlier step.
135
143
136
144
sudo mysql -u root -p
137
145
@@ -207,22 +215,24 @@ If you forget your root MariaDB password, it can be reset.
207
215
208
216
sudo systemctl stop mariadb
209
217
210
-
1. Then execute the following command which will allow the database to start without loading the grant tables or networking.
218
+
1. Then execute the following command which allows the database to start without loading the grant tables or networking.
0 commit comments