易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 40|回复: 5
收起左侧

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

[复制链接]
发表于 2024-7-23 15:43:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
创建mysql用户并创建对应的访问库  L: d3 ~* Y2 M, f# }1 E

) s9 Y/ r& N, `: }9 d
; y9 S  G. i( B6 NMariaDB [(none)]>  select distinct(User) from mysql.user;' o# T) G3 D+ ~: @9 J; I
+-------------+
1 y- W: e" ~4 j* O- [1 M: j: J| User        |
# J: u3 C8 B* y) z# c  n+-------------+0 e8 j$ X, m6 V" \( [! i! d; n
| mariadb.sys |
2 W; N. k: o1 v1 E9 _) V, i5 P| mysql       |
. V  C. G/ `( _| root        |
2 R' x4 t' k) [+-------------+
/ O* `. U0 t6 G3 rows in set (0.003 sec)
$ @" a5 a3 o' s0 ~# y% Z1 R* U. @. v) }9 Q0 u
MariaDB [(none)]> create user victor@'%' identified by 'victzzzz';1 J6 f( d1 K$ L# m+ `  `
Query OK, 0 rows affected (0.003 sec)
8 G4 w9 A% D0 F7 @
8 E) e4 h* V( v# D" }MariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'%' identified by 'victzzzz';/ j6 e7 I4 n. _, A
Query OK, 0 rows affected (0.001 sec): O. H" Q3 C5 u! F7 [. @. a
3 b( r: h2 |5 }
MariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'localhost' identified by 'victzzzz';
$ d; h, z: Y& {Query OK, 0 rows affected (0.002 sec)
2 k/ ~+ z! {3 T3 n! M) z! K& G9 |! l

, e, n+ f* B9 f9 s, Q2 c# t: X/ B" V. B! o
MariaDB [(none)]> create user victor@'%' identified by 'victxxxx;
+ ?6 D& U7 q/ X0 A6 w8 A- NQuery OK, 0 rows affected (0.003 sec)
- _8 I, r0 D/ v+ w
, X  m' Y# m" h, k. ^MariaDB [(none)]> create user victor@'localhost' identified by 'victxxxx';
2 J# j6 P5 |: ^Query OK, 0 rows affected (0.001 sec)
% e/ T  p# ?9 |& f( U5 D4 o% q# q% H/ M3 O) ]8 B' ]3 t' j- K
4 [0 t$ H2 z- ~  w; h# D) S
; u) M  i9 d7 |4 M4 h& E

' X; |! o! e( b7 T& p  v- q8 U$ R6 ^; W/ K
) {0 }- N  [0 H9 h. k( a
 楼主| 发表于 2024-7-23 15:44:09 | 显示全部楼层
MariaDB [(none)]> create database restflask ;9 j4 M: j: D2 L8 F* L
Query OK, 1 row affected (0.001 sec)
4 e/ v' d# \5 h9 M
 楼主| 发表于 2024-7-23 16:00:24 | 显示全部楼层
测试连接 带ip地址访问:/ j) @/ X7 \3 e  ?: T5 @
mysql -u victor -p2 w7 X8 f9 ?* R9 f3 J% a% N5 Z
Enter password: , F. a, B1 B% m, R! ]) ]
Welcome to the MariaDB monitor.  Commands end with ; or \g.
/ q6 J4 e" g; \! D6 b& f% G( f# @Your MariaDB connection id is 16
0 d) u, E5 {- k$ VServer version: 10.5.22-MariaDB MariaDB Server
* N* N( @% i$ P9 d5 `, a' q1 ~: v5 u+ l: ^; J$ C; r
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
! _8 x  d1 f8 w( `0 q# e" x
6 e1 r, ]6 P; b$ `; uType 'help;' or '\h' for help. Type '\c' to clear the current input statement.! p- w) N: t2 J+ j5 r' I

9 }. a# e% ?. }, m5 _% eMariaDB [(none)]> show databases;& j7 ~& x/ C! K4 H" g  [' A7 f5 Q( a, O
+--------------------+
2 v' \) r$ P4 X9 v1 K7 Y$ v| Database           |, N! d9 D5 V# a
+--------------------+4 t5 Y! [" z+ z; M- o3 z4 z- [
| information_schema |! U* f$ `( D, J5 R+ S( i+ b6 K
| restflask          |
6 F$ |4 {6 z& v4 d5 O2 j% J8 Z+--------------------+
( S( h1 |6 R. [" D2 rows in set (0.001 sec)
( n  S& m, v- S' s
2 W4 b5 }8 Q. `2 D0 uMariaDB [(none)]> use restflask
1 j- R% I+ S# [% S- NDatabase changed
9 K# q$ V, U6 {. b, wMariaDB [restflask]> show tables;
! f' A9 v) S2 k6 t  bEmpty set (0.000 sec)4 q! w/ V/ w/ S6 b% l& Z
* k! P& j; U6 J2 D
MariaDB [restflask]> exit
+ [3 r0 }3 X0 h7 G: B  lBye/ ?6 ]) {, \) `7 Y0 s
[root@python-flask mysqlclient-2.2.4]# mysql -u victor -p -h 192.168.13.131& m* S( B" l4 I& L1 c  u% Q$ Y  S2 [
Enter password:
" [, f6 T$ t! a' JWelcome to the MariaDB monitor.  Commands end with ; or \g.
; m6 w$ N8 }- g. j( [( V/ C: wYour MariaDB connection id is 173 Z' h4 o" C2 e/ r% s8 L
Server version: 10.5.22-MariaDB MariaDB Server: B) q; H# R8 c3 B) h
9 M9 \  U( l3 N2 S7 @- s
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.. d3 y( h0 H( T7 Y' F: G! F7 K4 {- G
: \& N' v. r* i- G. C
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
/ A- U! Z2 t) E$ ?2 b6 @$ {7 s1 Z
9 F- N, t: t4 O$ E$ e0 e, |MariaDB [(none)]> exit8 G9 _, `6 V' Z6 x5 W9 N
Bye
" O9 X) S* V  _3 X+ H
 楼主| 发表于 2024-7-25 07:18:15 | 显示全部楼层
MariaDB [(none)]>  create user victor@'%' identified by 'xxxx';$ p5 O; t/ e, @3 M6 h7 Q
Query OK, 0 rows affected (0.004 sec)
9 b8 |2 ^0 Y, z% n6 u
% O% s  ^1 Z9 @$ |6 [& pMariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'%' identified by 'xxxx';
. D+ {. N& b; F# v/ u4 F& SQuery OK, 0 rows affected (0.001 sec)
: ]4 }6 t! q0 R! R) Q7 Y2 c. J  _5 l: l$ x# R4 s  s; k
MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'localhost' identified by 'xxxx';- Q3 t% x6 M: y" Z( Y
Query OK, 0 rows affected (0.002 sec)
2 E8 F1 y$ {8 Z6 y9 h2 t4 C2 \9 D# x. V
 楼主| 发表于 2024-7-27 00:12:19 | 显示全部楼层
MariaDB [(none)]> CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ ;
% o9 Z1 |1 \$ x/ t% {2 ]+ ]Query OK, 1 row affected (0.005 sec)
) N! n2 b$ F1 W7 J$ r1 q% n2 L. p
 楼主| 发表于 2024-7-30 22:54:02 | 显示全部楼层
MariaDB [(none)]> show create database testflask
& i9 v' Y) o4 p: J) I, I1 b  L" w    -> ;6 c1 V( u5 ~, {0 G" W% F' W
+-----------+--------------------------------------------------------------------------------------------------+' \1 s3 f9 P, m+ [
| Database  | Create Database                                                                                  |
0 K' \; N' ~6 A9 I4 h9 G! _* V+-----------+--------------------------------------------------------------------------------------------------+. l$ @( q& d7 Y* t
| testflask | CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ |% o+ n2 Q) V, u" e- E! h. p6 O
+-----------+--------------------------------------------------------------------------------------------------+9 o9 ]" o! G' F) g5 `
1 row in set (0.001 sec)
% g& A& R" C2 B" ?' n; D8 C+ G' \
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:19 , Processed in 0.047550 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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