1.1 Questions
This example requires a simple management operation that is familiar with the MARIADB database and accomplishes the following tasks:
将 MariaDB 数据库的管理密码设为 1234567新建一个名为 newdb1 的数据库删除名为 test 的数据库授权数据库用户 zhsan 可从本机访问任何数据库,拥有所有权限,访问密码为 pwd123
1.2 Steps
The implementation of this case needs to follow the steps below.
Step one: Set the admin password for the MariaDB database to 1234567
1) Set the admin password
Because the default database administrator root password is empty, the old password does not need to be specified the first time a new password is set.
[[email protected] ~]# mysqladmin -uroot password ‘1234567‘[[email protected] ~]#
2) Verify the admin password
Connect the native database service with the administrative password you just set.
[[email protected] ~]# mysql -uroot -p1234567Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 3Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.MariaDB [(none)]> //以新密码成功登入MariaDB [(none)]> quit
Step Two: Create a new database named NEWDB1
1) Connect to the database as Administrator root
[[email protected] ~]# mysql -uroot -p1234567.. ..MariaDB [(none)]>
2) View the list of existing databases
MariaDB [(none)]> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test |+--------------------+4 rows in set (0.01 sec)
3) Create a new library named NEWDB1
MariaDB [(none)]> CREATE DATABASE newdb1;Query OK, 1 row affected (0.00 sec)
4) Review the existing database list again to confirm that the new library NEWDB1 is already in the column
MariaDB [(none)]> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mysql || newdb1 || performance_schema || test |+--------------------+5 rows in set (0.00 sec)
Step three: Delete the database named test
1) Delete Library test
MariaDB [(none)]> DROP DATABASE test;Query OK, 0 rows affected (0.00 sec)
2) View the list of libraries to confirm the results
MariaDB [(none)]> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mysql || newdb1 || performance_schema |+--------------------+4 rows in set (0.00 sec)
Step four: Authorize the new database user Zhsan
1) New Database user Zhsan
Enables new user Zhsan to access any database from this computer, with all permissions and access to password pwd123.
MariaDB [(none)]> GRANT all ON *.* TO [email protected] IDENTIFIED BY
Disconnect the database and exit.
MariaDB [(none)]> quitBye[[email protected] ~]#
2) database system connected to the native computer by the database user Zhsan
[[email protected] ~]# mysql -uzhsan
Configuration Database server for Linux