易陆发现互联网技术论坛

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

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

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

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

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

x
创建mysql用户并创建对应的访问库
2 v0 L3 R7 T! Q- T, Q2 P2 M  n- P' Z9 p+ p  X8 H
, p0 r/ s$ d; u! v) `0 {
MariaDB [(none)]>  select distinct(User) from mysql.user;6 ?9 s. E- U# ]; W3 `
+-------------+3 `+ E9 h2 Z0 D5 H' d$ N( i
| User        |1 a, F' T! \3 X
+-------------+, U6 ^5 @1 y) o) L4 g
| mariadb.sys |
2 V: C& Q& i  B| mysql       |
4 ~4 U' J; t$ S. U: J) U| root        |5 [% g( ^0 G/ K
+-------------+
5 P; \/ ]0 ?* @: s* v9 h3 rows in set (0.003 sec)1 V( h: {, F6 G1 R( k7 h. g

3 X5 R$ C2 X0 _* ?1 nMariaDB [(none)]> create user victor@'%' identified by 'victzzzz';
1 A5 ?+ D+ p0 L; Z( m3 v0 JQuery OK, 0 rows affected (0.003 sec)
- D' U/ e7 x$ N
$ J0 o5 s5 e! x; H) YMariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'%' identified by 'victzzzz';
% f/ g+ |2 Q) ~' M3 Z- S, h) x- bQuery OK, 0 rows affected (0.001 sec); t# t0 S$ V- J4 l4 |2 }
0 I4 Q; z+ ?' y: b# L7 [
MariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'localhost' identified by 'victzzzz';
& v8 ^3 R9 }+ L& j$ v5 ^Query OK, 0 rows affected (0.002 sec)
' t' x  k' ~0 A4 A. P+ Q. F, u9 L/ I
' u9 o% N. W/ a* L# m

2 `/ `' G- J' c8 VMariaDB [(none)]> create user victor@'%' identified by 'victxxxx;
2 v2 s5 v  A, z4 \Query OK, 0 rows affected (0.003 sec)
6 D& ^; u0 I1 S. v/ `$ H+ j( m; u1 B0 V# [9 C2 E' R$ _
MariaDB [(none)]> create user victor@'localhost' identified by 'victxxxx';
$ l2 h2 B" U* K# u+ ~9 E+ {; `Query OK, 0 rows affected (0.001 sec)
6 u2 H2 A) P& ~& g7 q: U* P9 G: F( K) z# K* q, v

3 S* v) y& M: w! s
2 p) \1 J( K; q2 k) q8 z, t/ N7 u4 G; c
) D6 H+ N" P6 I1 ?0 k$ u' k
+ O& s. U; P& D( u
; M' w# s/ r, P" A! a
 楼主| 发表于 2024-7-23 15:44:09 | 显示全部楼层
MariaDB [(none)]> create database restflask ;2 w( h6 x- s3 l% p
Query OK, 1 row affected (0.001 sec)* A0 g% |; o8 U; _1 i+ X
 楼主| 发表于 2024-7-23 16:00:24 | 显示全部楼层
测试连接 带ip地址访问:9 S5 g0 L. E; \8 T1 a# U- A( x' m
mysql -u victor -p# {( \: Q1 q3 }5 \+ E
Enter password: 4 z8 w' o5 Y* m, J* o4 E8 h
Welcome to the MariaDB monitor.  Commands end with ; or \g.8 d8 c0 ?$ x+ {8 L. ]
Your MariaDB connection id is 16
+ a& H$ d* ]4 SServer version: 10.5.22-MariaDB MariaDB Server; t2 F. _. f  X* _

7 e% s" \3 r3 m) a# H7 i; j: N, U# yCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.1 ~: b* f: ~0 ^  `; n& Y- J
1 G1 `, W+ J: K4 E/ `, Y* f" V4 H
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# \% o+ G2 O! T: r! u4 G* Y* \0 o. x5 \- R1 O& k/ N9 ~" a. k
MariaDB [(none)]> show databases;( V5 v  S. N! g& [5 |
+--------------------+
2 l9 A; [4 N: \7 d| Database           |" ]- O7 a& {/ |6 _1 L
+--------------------+/ {$ M8 N0 L7 z3 N  _% l# M) Z
| information_schema |
! t; K) o1 n5 A/ b, m| restflask          |
) @& ^+ F: `5 G2 U- k, Z/ ^+--------------------+( _& \9 ?# _1 _" {. C
2 rows in set (0.001 sec)
6 A1 u+ P( x. o9 V; W# c% h1 a& X1 ^5 `' Q8 Y9 R
MariaDB [(none)]> use restflask% A/ g. u, d1 p& _/ v1 S
Database changed
+ A1 f' c: V7 E6 cMariaDB [restflask]> show tables;
& s- ]% \2 r! A  iEmpty set (0.000 sec)4 V+ K$ B) G9 j" h

% H- N6 Y4 W7 ~MariaDB [restflask]> exit
# |/ S2 A7 j9 k% ^% a% `Bye$ N4 v! _' e: r+ d; F* X
[root@python-flask mysqlclient-2.2.4]# mysql -u victor -p -h 192.168.13.131
# U7 `6 m) G  X/ ?+ u/ OEnter password: 1 ^. B8 T6 R% E# Y: E
Welcome to the MariaDB monitor.  Commands end with ; or \g.% t& k* }9 Y7 q& U
Your MariaDB connection id is 17% t$ Q3 {* x2 k1 I7 k/ p1 c1 _
Server version: 10.5.22-MariaDB MariaDB Server
: c) Y' W7 e9 `& Z9 R% c; e1 e( c' s" E: C) H
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
( n  I' X5 X( V0 Q9 k, E/ O3 \3 c+ V% W. G
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
1 ~' o0 v  e2 s, ?( R$ n6 k
2 O" @+ T  g) i: W* tMariaDB [(none)]> exit
, j7 A* [. C% e% f8 q# o* `Bye- m; }/ D. [! i7 i) Q$ s% |
 楼主| 发表于 2024-7-25 07:18:15 | 显示全部楼层
MariaDB [(none)]>  create user victor@'%' identified by 'xxxx';0 M* l2 |2 U3 ^, a
Query OK, 0 rows affected (0.004 sec)* c7 i2 ~+ V& g1 y& Y* z. E, P
$ |* B9 |; ~0 A: K" b6 a. c3 L
MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'%' identified by 'xxxx';- F! Z# I! I1 ~: W! G/ V7 D; Z
Query OK, 0 rows affected (0.001 sec)
- d+ [, z* N7 O0 N
% R* R; {5 F/ }0 T* U7 t- V& ~2 j* |MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'localhost' identified by 'xxxx';* \9 U/ r! M3 z( [. u! v" v; {
Query OK, 0 rows affected (0.002 sec)
* _) F9 b/ _1 ^4 C- ?* R& x+ c) d
 楼主| 发表于 2024-7-27 00:12:19 | 显示全部楼层
MariaDB [(none)]> CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ ;
4 g( f7 h6 K2 t- fQuery OK, 1 row affected (0.005 sec)
# @' S5 M- S/ C# ^1 w. \8 \6 Y
 楼主| 发表于 2024-7-30 22:54:02 | 显示全部楼层
MariaDB [(none)]> show create database testflask* T$ \8 O" {/ Z% @. R9 ^  i
    -> ;7 k4 K" q0 V0 H1 J
+-----------+--------------------------------------------------------------------------------------------------+, ?& W" c( A2 z! d% v( I8 d6 G
| Database  | Create Database                                                                                  |
& C0 N; t, \9 ]  m- `; P& R+-----------+--------------------------------------------------------------------------------------------------+7 e# Y$ L! B2 K5 x1 E4 B% y" A/ I
| testflask | CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ |
9 B+ f% V% u( S( I) Z# C6 i6 V+-----------+--------------------------------------------------------------------------------------------------+1 h/ e- ]* h  ~0 Q7 B
1 row in set (0.001 sec); J/ g6 r, T1 \6 n- a6 ~
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-8 20:18 , Processed in 0.044925 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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