0

I'm following this tutorial to install mariadb on macOs Mojave. And I'm still have an issue when I try to secure it with mariadb-secure-installation

touch: .my.cnf.16016: Permission denied
touch: .mysql.16016: Permission denied
chmod: .my.cnf.16016: No such file or directory
chmod: .mysql.16016: No such file or directory

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
/usr/local/bin/mariadb-secure-installation: line 249: .my.cnf.16016: Permission denied
/usr/local/bin/mariadb-secure-installation: line 250: .my.cnf.16016: Permission denied
/usr/local/bin/mariadb-secure-installation: line 251: .my.cnf.16016: Permission denied
/usr/local/bin/mariadb-secure-installation: line 253: .my.cnf.16016: Permission denied
/usr/local/bin/mariadb-secure-installation: line 218: .mysql.16016: Permission denied
/usr/local/bin/mariadb-secure-installation: line 220: .mysql.16016: No such file or directory
Enter current password for root (enter for none): 

I've tryed this without success:

ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
SET PASSWORD = PASSWORD('my_secret_password');

When I do mysql.server status I've got

 ERROR! MariaDB is running but PID file could not be found

Somebody could help me on this please :)

Do I have to cleanup mysql ?

Lo1176
  • 29
  • 6
  • By root user, they were referring to the system root user, not a DB 'root' user. Try running the installation command with sudo. – Noah May Apr 18 '21 at 12:26
  • Thanks for your answer but when I do `sudo mariadb-secure-installation` I've got this error : ```Enter current password for root (enter for none): ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)``` – Lo1176 Apr 19 '21 at 08:05
  • Hi again @NoahMay, It finally worked. Maybe my server was stopped when I tryed the 'sudo mariadb-secure-installation` Thanks for your help – Lo1176 Apr 19 '21 at 08:26

1 Answers1

1

I solved this error with the Noahmay's suggestion (sudo mariadb-secure-installation)

So I first started mySql server:

mysql.server start 
Starting MariaDB
 SUCCESS!

Then I setup a new password with mysql_native_password. Honestly I don't really know if it is necessary.

➜  ~ mariadb

MariaDB [(none)]> ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
Query OK, 0 rows affected (0.012 sec)

MariaDB [(none)]> SET PASSWORD = PASSWORD('put_your_password_here');
Query OK, 0 rows affected (0.009 sec)

MariaDB [(none)]> exit
Bye

Then you can put this magic line and finish to secure MariaDB

➜  ~ sudo mariadb-secure-installation

I hope it will help macOs users.

Lo1176
  • 29
  • 6