If I do "mysqld --initialize-insecure", it will be fine with login after initialization, but if I omit "insecure", that will be secure initialization, after which I need a password to login, but I haven't set any password yet.
The menu data-directory-initialization-mysqld indicates that "Regardless of platform, use --initialize for “secure by default” installation (that is, including generation of a random initial root password). In this case, the password is marked as expired and you will need to choose a new one."
I thought that would be the problem, that mysql initializes the super administrative account "root" with a "random password" and "marked as expired", I need to "choose a new one", but how?
Should I try mysqld --initialize -p 'mypassword'
or should I type some other prompt clause after initialization?
This problem really bothers me(for twice, I gave up last time after a long time solution searching), indeed I do not need a secure mode to serve data just for testing my app locally, but I'd like to know how to initialize a secure root account for further usages.
I am not sure what I am missing after reading the manu and google it for 4 hours , again.
Thank you.
Use the following procedure to set a root password. To change the root password, type the following at the MySQL/MariaDB command prompt: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyN3wP4ssw0rd'; flush privileges; exit; Store the new password in a secure location.
The default user for MySQL is root and by default it has no password.
You simply logged in with the root
user and the given password which was generated when you use the --initialize
option. From
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization.html#data-directory-initialization-server-actions:
With --initialize but not --initialize-insecure, the server generates a random password, marks it as expired, and writes a message displaying the password:
[Warning] A temporary password is generated for root@localhost: iTag*AfrH5ej
When you logged in you can change the password with ALTER USER
. Still from https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization.html#data-directory-initialization-password-assignment:
Start the server. For instructions, see Section 2.10.2, “Starting the Server”.
Connect to the server:
[...]
After connecting, assign a new root password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With