mysql数据库用户的创建_mysql创建用户及数据库
登陸mysql
[root@dn210120 conf]# mysql -uroot
創(chuàng)建用戶及密碼
mysql> grant usage on *.* to 'hive14'@'localhost' identified by '123456' with grant option;
創(chuàng)建數(shù)據(jù)庫
mysql> create database hive14 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
賦予新用戶操作新數(shù)據(jù)庫的權(quán)限
##本地訪問
mysql> grant all privileges on hive14.* to hive14 identified by '123456';
##遠(yuǎn)程訪問
mysql> grant all privileges on hive14.* to hive14@'%' identified by '123456';
##刷新全局權(quán)限
mysql> flush privileges; 碰到問題:
不能直接使用insert語句進(jìn)行新增用戶
mysql> insert into mysql.user(Host,User,Password) values("localhost","hive14",password("1234"));
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
創(chuàng)建用戶時(shí)只能指向本機(jī),否則本機(jī)登陸不了mysql
grant usage on *.* to 'hive14'@'%' identified by '123456' with grant option;
其它知識:
修改autocommit屬性值
[root@dn210120 ~]# vi /etc/my.cnf
##增加autocommit=0,不自動提交
autocommit=0
[root@dn210120 ~]# service mysql restart
另外一種創(chuàng)建方式:
[root@dn210120 dbgen]# mysql
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 1103
Server version: 5.6.19-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, 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 'tpch'@'%' identified by 'tpch';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'tpch'@'%' identified by 'tpch';
Query OK, 0 rows affected (0.00 sec)
mysql> create database tpch;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on tpch.* to 'tpch'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> use tpch;
Database changed
mysql> show tables;
Empty set (0.00 sec)
總結(jié)
以上是生活随笔為你收集整理的mysql数据库用户的创建_mysql创建用户及数据库的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Pytorch神经网络实战案例】15
- 下一篇: oracle数据库存储ip地址,orac