原创

mysql用户相关操作

创建用户

mysql> CREATE USER 'demo'@'%' IDENTIFIED BY 'demo123';
> OK
> 时间: 0.308s

给新用户授权访问指定数据库

mysql> GRANT ALL PRIVILEGES ON demodb.* TO 'demo'@'%';
> OK
> 时间: 0.012s

刷新mysql权限

mysql> FLUSH PRIVILEGES;
> OK
> 时间: 0.036s

mysql登录

[root@demo ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2066
Server version: 8.0.37 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

修改用户密码

alter user root identified by '123456';
正文到此结束