mysql数据库命令行将刚建的数据库的所有权限给一个先建用户

来源:互联网 发布:java有没有链表 编辑:程序博客网 时间:2024/06/04 17:45

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with?; or /g.
Your MySQL connection id is 5340 to server version: 3.23.54
 
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
 
mysql> CREATE DATABASE hello;
Query OK, 1 row affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON hello.* TO "newuser"@"localhost" IDENTIFIED BY "newpwd";
Query OK, 0 rows affected (0.00 sec)
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT
Bye
$

 

顺便说下改用户密码,修改用户密码,要use mysql,必须到这个database 下,然后

update user set password=password("newpwd") where user="theuser";

 

接着还想说下souce命令,因为这个用得教多了,source命令是将sql脚本文件导入到数据库中,首先你的先建一个数据库use了这个数据库之后,在

source "路径名"+/thefile.sql