第一种方法:
[root@localhost ~]# mysqladmin -uroot -p000000 drop test
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the 'test' database [y/N] y
Database "test" dropped
[root@localhost ~]# mysql -uroot -p000000
MariaDB [(none)]> create database test; //因为我们drop 了 test 数据库它也就不在了,需要再创建一个
[root@localhost ~]# mysql -uroot -p000000 test < test.sql //恢复到指定的数据库
第二种方法:
[root@localhost ~]# mysqladmin -uroot -p000000 drop test
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the 'test' database [y/N] y
Database "test" dropped
[root@localhost ~]# mysql -uroot -p000000
MariaDB [(none)]> create database test;
MariaDB [test]> use test
Database changed
MariaDB [test]> source /root/test.sql
4:添加用户并授权
#授权root用户可以在任何节点访问 test 数据库下的所有表, “ % ” 代表所有节点
MariaDB [(none)]> GRANT ALL PRIVILEGES ON test. * TO 'root'@'%' IDENTIFIED BY '000000';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON test. * TO 'root'@'localhost' IDENTIFIED BY '000000';
#添加root用户对test数据库增、删、改、查的权限
MariaDB [(none)]> GRANT SELECT,INSERT,DELETE,UPDATE ON test. * TO 'root'@'%' IDENTIFIED BY '000000';