VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: n Using existing password for root. Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success.
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success.
By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success.
- Removing privileges on test database... Success.
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success.
All done!
修改密码
修改用户密码,记得先登录mysql的root用户。
1 2
alter user '用户名'@'%' identified by '密码'; alter user '用户名'@'%' identified with mysql_native_password BY '密码';
操作 MySQL
登录
1
mysql -uroot -p
创建新用户
1 2 3 4
#默认 create user '用户名'@'%' identified by '密码'; #指定mysql_native_password插件 create user '用户名'@'%' identified with mysql_native_password by '密码';
先使用mysql -uroot -p进行登录
1 2 3
create user 'lcf'@'%' identified with mysql_native_password by '123456';
create user 'lyy'@'%' identified by '123456';
我们可以看到lcf和lyy的密码插件不同。
授权
1 2 3 4 5 6 7
grant all privileges on database_name.* to 'username'@'%'; -- 'database_name' - 赋予权限的数据库名称 -- 'username' - 用户名 -- 'localhost' - 用户只能在本地访问数据库
# 全部数据库 grant all privileges on *.* to 'username'@'%';