1、增加一个数据库
例如:创建一个wrx的数据库
[root@wrx ~]# mysql -uroot -p #登录数据库控制台 Enter password: #输入root账号密码,密码默认不显示 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 527 Server version: 5.5.54 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2016, 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 database wrx; #创建一个wrx的数据 Query OK, 1 row affected (0.02 sec) mysql> show databases; #显示所有创建的数据库 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | wp | | wrx | +--------------------+ 13 rows in set (0.00 sec) mysql> exit; Bye [root@wrx ~]#
2、删除一个数据库
例如:删除wrx数据库
[root@wrx ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 533 Server version: 5.5.54 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2016, 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> drop database wrx; Query OK, 0 rows affected (0.04 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | wp | +--------------------+ 12 rows in set (0.00 sec) mysql> exit; Bye [root@wrx ~]#
3、创建数据库用户
例子:为wrx数据库创建 一个用户名为wmrx,密码为123456。授权为本机localhost 对wrx 数据库所有权限
[root@wrx ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 549 Server version: 5.5.54 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2016, 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 wrx.* to wmrx@'localhost' -> identified by '123456'; Query OK, 0 rows affected (0.03 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye