安装msyql,启动服务,修改/etc/my.cnf 中
sql_mode=NO_ENGINE_SUBSTITUTION(其他略)
[root@localhost mysql]# mysql -uroot -p
Enter password: (密码不显示)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.44 MySQL Community Server (GPL)Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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> grant all privileges on *.* to t1@'%' identified by '1';
// all privileges:数据库所有操作权限
//*.* :所有库.所有表
// t1 : 用户名
//'%' :允许访问的所有非本机地址
// '1' :密码
//具体百度
Query OK, 0 rows affected (0.00 sec)mysql> grant all privileges on *.* to t1@'localhost' identified by '1'; //(上面一个 '%'指所有非本地主机)
Query OK, 0 rows affected (0.01 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye
[root@localhost mysql]# systemctl restart mysql //重启mysql服务
[root@localhost mysql]# mysql -ut1 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.44 MySQL Community Server (GPL)Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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>
搞定,就是这么简单,教程不可怕,怕的是自己和别人跑的结果不一样,各种状况!
End
centos7 mysql5.6 极简增加用户 并授权
最新推荐文章于 2021-02-05 16:54:16 发布