The "Access denied for user 'root'@'localhost'" error occurs because you're trying to run `mariadb-secure-installation` as the root user, but it's asking for the current root password, which you may not have set during the installation. Here's how you can proceed:
1. **Reset the MariaDB Root Password**: If you don't have the current root password, you can reset it. Follow these steps:
a. Stop the MariaDB service:
```bash
sudo systemctl stop mariadb
```
b. Start MariaDB in safe mode to bypass authentication:
```bash
sudo mysqld_safe --skip-grant-tables &
```
c. Open a new terminal window and log in to the MySQL prompt without a password:
```bash
mysql -u root
```
d. Now, reset the root password. Replace `your_new_password` with your desired password:
```sql
USE mysql;
UPDATE user SET password = PASSWORD('your_new_password') WHERE user = 'root';
FLUSH PRIVILEGES;
EXIT;
```
e. Stop the MariaDB safe mode instance:
```bash
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
```
2. **Run `mariadb-secure-installation`**: After resetting the root password, you should be able to run `mariadb-secure-installation`:
```bash
sudo mariadb-secure-installation
```
When prompted for the current password, enter the new password you set in step 1. Follow the prompts to secure your MariaDB installation.
This should allow you to set the root password and perform the initial setup for MariaDB without encountering the "Access denied" error.