当前位置: 首页 >数据库 > Mariadb监视器

Mariadb监视器

[root@localhost ~]# mysql -uroot -pflectrag  #登录root账户
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 10.5.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;#展示所有数据库
+--------------------+
| Database |
+--------------------+
| acme |
| information_schema |
| mariadb |
| mysql |
| performance_schema |
+--------------------+
5 rows in set (0.001 sec)

MariaDB [(none)]> drop database acme;#删除acme数据库
Query OK, 5 rows affected (0.015 sec)

MariaDB [(none)]> create database acme;#创建acme数据库
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> use acme;#选择acme数据库
Database changed
MariaDB [acme]> source /root/acmeDB.dump;#编译脚本
Query OK, 0 rows affected, 1 waing (0.000 sec)

Query OK, 0 rows affected (0.004 sec)

Query OK, 1 row affected (0.001 sec)

Query OK, 1 row affected (0.001 sec)

Query OK, 1 row affected (0.001 sec)

Query OK, 1 row affected (0.001 sec)

Query OK, 1 row affected (0.000 sec)

Query OK, 1 row affected (0.000 sec)

Query OK, 1 row affected (0.001 sec)

Query OK, 1 row affected (0.000 sec)

Query OK, 1 row affected (0.000 sec)

Query OK, 0 rows affected (0.004 sec)

Query OK, 0 rows affected (0.002 sec)
Records: 0 Duplicates: 0 Waings: 0

Query OK, 0 rows affected (0.002 sec)

Query OK, 0 rows affected (0.002 sec)

Query OK, 0 rows affected (0.002 sec)

Query OK, 1 row affected (0.000 sec)

Query OK, 1 row affected (0.000 sec)

Query OK, 1 row affected (0.000 sec)

MariaDB [acme]> grant select on acme.* to a@'localhost' identified by '123456';#创建一个只能本地登录的a用户对acme只有查询权限,密码123456
Query OK, 0 rows affected (0.005 sec)

MariaDB [acme]> \q#退出
Bye
[root@localhost ~]# mysql -ua -p#a用户登录
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.5.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
MariaDB [(none)]> show tables;
ERROR 1046 (3D000): No database selected
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| acme |
| information_schema |
+--------------------+
2 rows in set (0.000 sec)

MariaDB [(none)]> use acme ;
Reading table information for completion of table and column names
You can tu off this feature to get a quicker startup with -A

Database changed
MariaDB [acme]> show tables;
+----------------+
| Tables_in_acme |
+----------------+
| dept |
| tb_record |
| tb_replaied |
| tb_sureRecord |
| userinfo |
+----------------+
5 rows in set (0.001 sec)

MariaDB [acme]> desc dept;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| deptId | int(10) | NO | PRI | 0 | |
| deptNumber | varchar(100) | NO | | | |
| deptName | varchar(100) | NO | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.002 sec)

MariaDB [acme]> select * from dept;
+--------+--------------------+---------------------------+
| deptId | deptNumber | deptName |
+--------+--------------------+---------------------------+
| 1 | P14464778285479397 | 刑大-合成作战中队 |
| 2 | P14464561185246144 | 配侦部 |
| 3 | P14464561285246244 | 网监部 |
+--------+--------------------+---------------------------+
3 rows in set (0.000 sec)

MariaDB [acme]> insert into acme (deptID,deptNumber,deptName) VALUES (4,ppp,jinitaimei);#插入一条数据
ERROR 1142 (42000): INSERT command denied to user 'a'@'localhost' for table 'acme'#没有插入权限
MariaDB [acme]> updata dept set deptId=6 where deptId=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'updata dept set deptId=6 where deptId=1' at line 1#语法错误
MariaDB [acme]> update dept set deptId=6 where deptId=1;
ERROR 1142 (42000): UPDATE command denied to user 'a'@'localhost' for table 'dept'
MariaDB [acme]> delete form dept where deptId=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'dept where deptId=1' at line 1
MariaDB [acme]> delete from dept where deptId=1;
ERROR 1142 (42000): DELETE command denied to user 'a'@'localhost' for table 'dept'
MariaDB [acme]> \q
Bye
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 10.5.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use acme;
Reading table information for completion of table and column names
You can tu off this feature to get a quicker startup with -A

Database changed
MariaDB [acme]> use dept;
ERROR 1049 (42000): Unknown database 'dept'
MariaDB [acme]> insert into acme (deptID,deptNumber,deptName) VALUES (4,ppp,jinitaimei);
ERROR 1146 (42S02): Table 'acme.acme' doesn't exist
MariaDB [acme]> insert into dept (deptID,deptNumber,deptName) VALUES (4,ppp,jinitaimei);
ERROR 1054 (42S22): Unknown column 'ppp' in 'field list'
MariaDB [acme]> insert into dept (deptID,deptNumber,deptName) VALUES (4,'ppp','jinitaimei');
Query OK, 1 row affected (0.001 sec)

MariaDB [acme]> select * from dept;
+--------+--------------------+---------------------------+
| deptId | deptNumber | deptName |
+--------+--------------------+---------------------------+
| 1 | P14464778285479397 | 刑大-合成作战中队 |
| 2 | P14464561185246144 | 配侦部 |
| 3 | P14464561285246244 | 网监部 |
| 4 | ppp | jinitaimei |
+--------+--------------------+---------------------------+
4 rows in set (0.000 sec)

MariaDB [acme]> updata dept set deptId=6 where deptId=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'updata dept set deptId=6 where deptId=1' at line 1
MariaDB [acme]> updata dept set deptId=6 where deptId==1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'updata dept set deptId=6 where deptId==1' at line 1
MariaDB [acme]> update dept set deptId=6 where deptId=1;
Query OK, 1 row affected (0.003 sec)
Rows matched: 1 Changed: 1 Waings: 0

MariaDB [acme]> select * from dept;
+--------+--------------------+---------------------------+
| deptId | deptNumber | deptName |
+--------+--------------------+---------------------------+
| 2 | P14464561185246144 | 配侦部 |
| 3 | P14464561285246244 | 网监部 |
| 4 | ppp | jinitaimei |
| 6 | P14464778285479397 | 刑大-合成作战中队 |
+--------+--------------------+---------------------------+
4 rows in set (0.000 sec)

MariaDB [acme]> delete from dept where deptId=1;
Query OK, 0 rows affected (0.000 sec)

MariaDB [acme]> select * from dept;
+--------+--------------------+---------------------------+
| deptId | deptNumber | deptName |
+--------+--------------------+---------------------------+
| 2 | P14464561185246144 | 配侦部 |
| 3 | P14464561285246244 | 网监部 |
| 4 | ppp | jinitaimei |
| 6 | P14464778285479397 | 刑大-合成作战中队 |
+--------+--------------------+---------------------------+
4 rows in set (0.000 sec)

MariaDB [acme]>\q

Bye
[root@localhost ~]#

作者:老运维
来源链接:https://www.cnblogs.com/huluxia-fun/p/15744981.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/118512.html

分享给朋友:

“Mariadb监视器” 的相关文章

一文带你了解MySQL基础 2022年05月15日 09:35:43
MySQL事务和锁 2022年05月16日 21:54:37
MySQL主从复制 2022年05月17日 21:34:56
利用Oracle分析函数row 2022年06月03日 23:42:05
mysql查询最新的一条记录 2022年06月06日 16:04:12
Mysql查询某字段值重复的数据 2022年06月11日 19:39:22
mysql 近几天内 2022年06月15日 15:07:52