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.
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';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.