找回密码
 注册
查看: 48|回复: 5

创建mysql用户并创建对应的访问库

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-23 15:43:31 | 显示全部楼层 |阅读模式
创建mysql用户并创建对应的访问库
+ K6 a8 u4 I4 Z6 f( [+ T; J6 |3 F# i. V5 `$ @- I% ?) n; X
. X- C/ k& k- Z7 @  ^" P% h
MariaDB [(none)]>  select distinct(User) from mysql.user;( T8 Q- M# ?' p  s
+-------------+6 b* z5 @( R' @( n
| User        |- Z0 W  Y+ i  c4 [% @) z2 r5 p
+-------------+
' T  W* _! d# K6 O: ?| mariadb.sys |
7 x, G0 ?( j" T- u- [# H| mysql       |
1 E* I: b) k% [' u| root        |
  E; G- f( I6 F# D( g2 e8 C+-------------+. m" J! W+ O. F( }9 w
3 rows in set (0.003 sec)
9 u/ ~% Y; h: V  P9 k. h4 S
3 x, @+ S9 U5 v# ]9 N' ^MariaDB [(none)]> create user victor@'%' identified by 'victzzzz';/ ^# `% v* I3 @4 S% X* i
Query OK, 0 rows affected (0.003 sec)
1 K% L) S3 o$ A2 H1 \
" _0 }( R8 V3 `. X8 D& XMariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'%' identified by 'victzzzz';
7 X4 Q1 I9 U) G) a7 bQuery OK, 0 rows affected (0.001 sec)
; ^  t- S3 Y" I- E, y
' ^& H! s! E7 f' BMariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'localhost' identified by 'victzzzz';8 @( U7 p' Y% C5 A$ V- e4 ?1 d
Query OK, 0 rows affected (0.002 sec)# S2 F8 e7 @0 C6 r6 O

. g! K4 o: }4 ^  T2 q$ H4 a7 ~* E& O" o0 z, h1 U
3 b0 M& Q/ A. ~4 d5 A% P. u
MariaDB [(none)]> create user victor@'%' identified by 'victxxxx;
! Z% [/ G% }! x! ]Query OK, 0 rows affected (0.003 sec)6 A  @" H: c4 x# i9 h

9 T1 R8 j$ ?$ G& V- r4 _MariaDB [(none)]> create user victor@'localhost' identified by 'victxxxx';
! l! F# e: W) c9 ^2 x0 Q( @& J* sQuery OK, 0 rows affected (0.001 sec)
, R. B; a$ n2 H; r. I
$ G$ m" e, [  G7 ?
4 I8 V  m" d; h& T. F3 S
  P& _; c1 P, ?: J0 n  }; q
0 l! g& e- N3 Q" W
9 }5 }0 n( m/ j7 `8 i- E/ y: u: n, l  v* M' H4 {

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-23 15:44:09 | 显示全部楼层
MariaDB [(none)]> create database restflask ;
. g6 v' j7 Y& J; Z5 ?& ~2 eQuery OK, 1 row affected (0.001 sec)
4 d" F% h! i% L8 e) U5 w& s$ ^

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-23 16:00:24 | 显示全部楼层
测试连接 带ip地址访问:
+ u0 i1 L% s  u mysql -u victor -p
1 G# J3 d' q, HEnter password: ( X6 d& n+ @/ A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
& G' N( u5 a1 p3 oYour MariaDB connection id is 16
0 g5 O& E/ B3 bServer version: 10.5.22-MariaDB MariaDB Server9 \' U! x: z% H  B$ h* d

; O% z1 N7 z% c0 y, M$ pCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
" Q2 T+ t. Z1 R( R! H$ p- T! u
2 }% y# }" i: n, E7 D: ~! T$ YType 'help;' or '\h' for help. Type '\c' to clear the current input statement.. ^# q  u8 r6 j  a$ ]2 V
/ Y( s% @& Q" B; n8 z+ f0 f
MariaDB [(none)]> show databases;; \2 w1 h/ b; t& v2 u
+--------------------+
1 _& N7 a& v! ?8 m| Database           |8 j  [1 Q5 \5 L$ p  l4 |
+--------------------+
2 {" A6 C" ~! Q6 t| information_schema |
& D+ i( J4 E0 l/ f| restflask          |
: W& B6 s: Y5 w/ o+--------------------+
2 `& T7 x( A, C) A7 k$ `5 f% Y2 rows in set (0.001 sec)
; B) @$ P- N- j5 n+ R/ J: v0 r- l. n8 l0 i6 ?
MariaDB [(none)]> use restflask' |. d5 z# o6 W7 ]
Database changed
$ D* B. m7 I: W+ j" B# F0 O$ d; PMariaDB [restflask]> show tables;
' t4 E& d7 `" O7 x* iEmpty set (0.000 sec)
3 Z6 d! {, r$ t
0 ?/ Y; _) D1 s0 q( P6 |MariaDB [restflask]> exit- b5 h9 w9 x7 x; W3 |* D6 ?8 l
Bye. N  b$ U' m# {2 h# i; q
[root@python-flask mysqlclient-2.2.4]# mysql -u victor -p -h 192.168.13.131
3 T# @& p/ v4 HEnter password:
9 R: m; i3 C  ]2 d' E5 U/ OWelcome to the MariaDB monitor.  Commands end with ; or \g.
" @) Z$ ]3 q2 T& x( bYour MariaDB connection id is 17$ g' R2 S& c+ T
Server version: 10.5.22-MariaDB MariaDB Server
0 M6 y4 n- |) m5 @) w5 M  g  ~+ R( `. G
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.& q* [' Y0 }0 N* |% O' x
9 T% P, d7 I" W8 Q9 f
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.! z. ?3 g* s0 \

' n( B8 a+ S  o4 l6 D, T; Z4 t/ IMariaDB [(none)]> exit
# Q+ v+ x2 R/ X$ w% a9 tBye& L4 r2 L. p) y" L4 t

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-25 07:18:15 | 显示全部楼层
MariaDB [(none)]>  create user victor@'%' identified by 'xxxx';
% H  M$ L: \& P2 n9 JQuery OK, 0 rows affected (0.004 sec)
, Y) Y, g/ Y+ Z: g: f( v5 A, @
0 Z8 {+ Z* E9 e+ m! E+ U& ?/ m! k/ dMariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'%' identified by 'xxxx';
( h7 O2 }1 B# w+ Q1 u+ U, O3 uQuery OK, 0 rows affected (0.001 sec)4 f3 i- A2 }: J9 A; I
% @" p1 h) d4 _$ W* R& X
MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'localhost' identified by 'xxxx';
% J% S- M: P. H5 \5 u) a2 tQuery OK, 0 rows affected (0.002 sec)
' E& z, |3 Q% t: `

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-27 00:12:19 | 显示全部楼层
MariaDB [(none)]> CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ ;, W$ b6 W! [5 [; z' @% `% O, D
Query OK, 1 row affected (0.005 sec)
7 d- }, ^; j% U. b

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-30 22:54:02 | 显示全部楼层
MariaDB [(none)]> show create database testflask
& u6 C" t* ?" A$ T    -> ;
" U5 b; p2 H9 ?9 w3 c+-----------+--------------------------------------------------------------------------------------------------+* ~7 u: }( Q' `5 E" ]
| Database  | Create Database                                                                                  |
) A  `! W+ T) u, d; S) K$ T$ ]+-----------+--------------------------------------------------------------------------------------------------+0 r2 w9 g7 R8 h
| testflask | CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ |
9 h) W8 [& @' I4 W6 \: f+-----------+--------------------------------------------------------------------------------------------------+
* z, U. p# ?! Q1 row in set (0.001 sec)
: M" }3 e, _% d$ k0 k7 Z; a2 V, u
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-11 23:03 , Processed in 0.019232 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表