创建用户
[root@hadoop1 yum.repos.d]# mysql -uroot -proot Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.43 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> CREATE USER 'bd-portal'@'%' IDENTIFIED BY 'bd-portal'; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select user,host from user; +-----------+----------------+ | user | host | +-----------+----------------+ | bd-portal | % | | root | % | | root | 127.0.0.1 | | root | ::1 | | | hadoop1.org.cn | | root | hadoop1.org.cn | | root | localhost | +-----------+----------------+ 7 rows in set (0.00 sec) mysql>
此时创建完了用户之后,我们用数据库连接工具连接:
此时创建数据:
授予权限
说明没有创建数据库的权限,此时进入root用户,创建好数据库,然后授予权限,如下所示:
mysql>CREATE DATABASE bd-portal DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; mysql>GRANT ALL PRIVILEGES ON `bd-portal`.* TO 'bd-portal'@'%' IDENTIFIED BY 'bd-portal'; mysql>FLUSH PRIVILEGES;
备注:mysql56同样有这方面限制。
坚壁清野