MySQL server admin pass setup

Hello,
I think I did’t choose wrong forum of this site to ask this:
I use OpenSUSE Leap 42.1 KDE. This morning I installed LAMP using YaST Pattern, but I have got problem (for the first time in my life) to setup mysql admin password. I used

mysqladmin -u root password zzzzzz;

Result was

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘mysqladmin -u root password zzzzzz’ at line 1

What is wrong? How could I set up my MySQL server root (admin) password?

Thank you in advance

The error is obvious: what you typed in is no valid SQL statement, mysqladmin is a shell command.

There are several ways to setup an admin password for MySQL/MariaDB, the easiest one is probably running this in a shell:

mysql_secure_installation

See also https://en.opensuse.org/SDB:MySQL_installation#Securing

What you tried to use:

mysqladmin -u root password zzzzzz

should work as well, but you need to type this into the shell, not mysql. I.e. run this without running mysql (the client) first.

Nowadays, what you’re asking for is a bit easier because MySQL/Mariadb comes with a configuration tool, and setting the mysqladmin password is only one of many required settings to get set up correctly.

On a new MySQL/Mariadb install, you should run the following script/command which will interactively walk you through the entire process including setting the MySQL Admin password (if you enable remote access)

mysql_secure_installation

If you want to configure your MySQL/Mariadb security non-interactively (ie as an automated install), IMO scripting the answers as I described in the following Wiki page is easiest because it doesn’t require installing new tools

https://en.opensuse.org/User:Tsu2/MySQL_and_Mariadb

HTH,
TSU