易陆发现互联网技术论坛

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

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

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

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

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

x
创建mysql用户并创建对应的访问库+ l' y1 B% X  e

% u& \4 h; W5 K& U* T' ]" ^
, F& M, O3 i# BMariaDB [(none)]>  select distinct(User) from mysql.user;& C! w7 ^  l7 U% t
+-------------+
5 Q% s/ J0 J9 I& J| User        |% d6 c; q+ [7 B9 \2 F6 k1 [: n
+-------------+1 u# O8 t' O! M& C2 f7 [, j3 @0 G) p
| mariadb.sys |
. A$ o1 y8 {  g( ^| mysql       |# N% |" {+ K1 |7 S# S- W% G+ f
| root        |3 I! G3 A: d$ R1 K8 k
+-------------+. Y/ p9 \2 N( Z1 K" g1 `
3 rows in set (0.003 sec)
7 V4 b8 y7 p/ I6 }; l' v" ?8 }4 t9 ?# K' D( o, S+ Y
MariaDB [(none)]> create user victor@'%' identified by 'victzzzz';
5 D# W  G3 i6 z7 L" ]/ ?' hQuery OK, 0 rows affected (0.003 sec)3 _+ x$ T' P- X

( W' [: C2 r& x6 v1 w! s- qMariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'%' identified by 'victzzzz';1 y! U2 Z) s8 |
Query OK, 0 rows affected (0.001 sec)
- k8 Y2 t; Z8 x- n8 j, G5 V% d; s5 w5 l
MariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'localhost' identified by 'victzzzz';
7 t2 o6 E/ E# F1 W% V& M2 K9 [Query OK, 0 rows affected (0.002 sec)! W4 b2 T1 l# p7 U
6 m7 ~/ c3 o, n: I3 ~5 Z, q! {
8 q. B3 n0 H$ m
. v8 d- ?( C  c2 A
MariaDB [(none)]> create user victor@'%' identified by 'victxxxx;
- g; v8 I! T! G7 rQuery OK, 0 rows affected (0.003 sec)
) H& r' a. W4 W9 o/ s$ Y
& Z1 g& N8 c' q8 Z# L# a9 JMariaDB [(none)]> create user victor@'localhost' identified by 'victxxxx';" `. k5 t; W' x% L% `4 P; w" a- e
Query OK, 0 rows affected (0.001 sec)
& C' z* ]" M2 J7 X( c1 O% n' H; U' h# k  l8 Y3 N2 `" r

, P) _! A( s) g6 |# P  l" H6 c' C6 k% U$ o

/ v$ R2 M6 X: c1 X+ [/ R6 p7 I# j8 G. `
: }8 t5 l1 p7 c3 N1 z& c% }$ D5 w$ [9 Z( j6 H9 I' T
 楼主| 发表于 2024-7-23 15:44:09 | 显示全部楼层
MariaDB [(none)]> create database restflask ;
5 L9 {% ?/ M7 w: q  JQuery OK, 1 row affected (0.001 sec)
+ A3 c) S( E% D2 J9 T
 楼主| 发表于 2024-7-23 16:00:24 | 显示全部楼层
测试连接 带ip地址访问:
  C2 P* @: h; F& V' W! M. U mysql -u victor -p% s) J. F9 s  u4 R) X
Enter password:
2 F0 P( P) n0 P* u% y+ J) kWelcome to the MariaDB monitor.  Commands end with ; or \g.
' O+ E. B: W3 \7 hYour MariaDB connection id is 16
0 U+ b, a0 t; m- }, bServer version: 10.5.22-MariaDB MariaDB Server
# }- X" P" n% g' f( q$ r1 L; a; _! l# J& b$ N% j0 L
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others./ c) i1 x0 {9 E! e7 R
+ c! g' u; D" I9 A' @4 H! n
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
5 P$ c- W4 _- i) b, _+ I% q2 J+ V9 i
MariaDB [(none)]> show databases;* S5 p( e# m# r/ M9 G* I' r" p; ]8 H
+--------------------+
2 g3 j# ]' K$ c5 n. || Database           |8 h! V' A6 \0 \0 o
+--------------------+  ~& S5 r6 J2 I, e- B
| information_schema |
1 z! R. W' b2 L. b0 o+ v5 ^% {| restflask          |
! V: S  a  s$ @* S+--------------------+
4 T# d2 G6 Y# E+ y& Z2 rows in set (0.001 sec)
( [( [) T7 |3 z8 W1 g, B5 U& u/ A4 N1 t# V1 p
MariaDB [(none)]> use restflask
; m/ ^3 }  W9 B% t1 gDatabase changed
6 K* A1 S; D+ }# g1 U1 n" M+ HMariaDB [restflask]> show tables;* W4 \  p( D6 l: N
Empty set (0.000 sec)9 x# x% F" v; B; x

5 |; U1 i, x# [& I2 EMariaDB [restflask]> exit
- I" @( {4 O2 b0 D5 NBye7 P$ Z" D6 s- K
[root@python-flask mysqlclient-2.2.4]# mysql -u victor -p -h 192.168.13.131
0 p# C0 v9 S6 sEnter password: & D) u/ j8 o. p" e7 w) v
Welcome to the MariaDB monitor.  Commands end with ; or \g.' |- |! {2 k5 y$ T* }
Your MariaDB connection id is 179 ^0 t( a; O+ ]3 T6 ?
Server version: 10.5.22-MariaDB MariaDB Server
1 e: a* \3 M& V, S: e) g
* p! O2 ~. G8 X0 RCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.) D! [1 R' D3 G8 A
8 l9 o. U9 ^7 j/ h
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
2 E( v0 |) g) C, ~# N9 R
  }# k' a3 {) l) [# M# d# qMariaDB [(none)]> exit7 h0 B# ?* w' W$ S2 ~, J: p3 T( I
Bye& V5 e/ m8 C; s1 J8 W8 _
 楼主| 发表于 2024-7-25 07:18:15 | 显示全部楼层
MariaDB [(none)]>  create user victor@'%' identified by 'xxxx';
. a* Q* c) m, WQuery OK, 0 rows affected (0.004 sec)% ?" E3 p" t" v: J! \
, n' @8 F: j8 g3 }0 D5 @1 B
MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'%' identified by 'xxxx';7 p4 o4 g+ L. f" g! i( ^
Query OK, 0 rows affected (0.001 sec)5 Z- `# k2 c9 G/ s; v: R( T5 ?- V! L
) U4 _+ U' W- e) @) }- E
MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'localhost' identified by 'xxxx';
+ H( [' w, |/ ^0 d& O7 mQuery OK, 0 rows affected (0.002 sec)
. o9 e9 [! `6 D7 b4 |
 楼主| 发表于 2024-7-27 00:12:19 | 显示全部楼层
MariaDB [(none)]> CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ ;' x2 x' ]4 F! n' |7 S. q) N
Query OK, 1 row affected (0.005 sec), x; P3 P/ ]) S/ f) I9 }4 c
 楼主| 发表于 2024-7-30 22:54:02 | 显示全部楼层
MariaDB [(none)]> show create database testflask: i# \; L9 @6 d) y( {  _
    -> ;
+ u8 |2 x- ?3 A# V* v2 e) |6 W2 |. p+-----------+--------------------------------------------------------------------------------------------------+6 P9 p7 I1 e. h# ?  f0 c
| Database  | Create Database                                                                                  |
0 w+ [, l: W- F/ a# Z, u, P$ A, {* i+-----------+--------------------------------------------------------------------------------------------------+# c0 _' |3 t% m! O. n
| testflask | CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ |
* U) {+ A, `' j* K* g/ v+-----------+--------------------------------------------------------------------------------------------------+
. H8 }+ J, t/ i- T, @* R# u1 row in set (0.001 sec)1 ?( o! _- ^6 e
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 13:43 , Processed in 0.040501 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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