易陆发现互联网技术论坛

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

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

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

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

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

x
创建mysql用户并创建对应的访问库
' z, u& f9 C$ O, G+ o. \% ]% T1 h9 `( A3 P6 m
. B) Y+ W! }4 d$ f% \9 @! F$ |
MariaDB [(none)]>  select distinct(User) from mysql.user;
! X+ z- N1 B& P6 P6 y* E+-------------+
5 h( P2 V: ~6 l8 {! I) _| User        |
/ I3 ?5 Q- d2 d; Z* \+ Z1 l) D+-------------+0 m% o% @9 c! P: s) u8 O$ l
| mariadb.sys |/ D* `3 m% N  [" E8 j" R- y; N
| mysql       |/ \6 l; x, a$ ?, [) e0 N
| root        |& \! ?2 G6 K/ q2 X+ V8 u
+-------------+5 |! L& S) ?+ ~
3 rows in set (0.003 sec)/ f" [) {8 B/ U" w( j
7 _8 E) }) z( S9 y0 g4 U% `3 j2 Z: i6 @
MariaDB [(none)]> create user victor@'%' identified by 'victzzzz';; V1 }; ^& s7 T) |( w5 {
Query OK, 0 rows affected (0.003 sec). q9 Y8 z& h$ X9 i2 R: W- {

% E1 u! L  W- b1 X4 j% r( U( EMariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'%' identified by 'victzzzz';" i& e* P8 g  ?# X) H* W
Query OK, 0 rows affected (0.001 sec)4 t" \9 Y- L( ?3 S4 i  `
  ?: D7 d% z4 ]4 f
MariaDB [(none)]> grant ALL PRIVILEGES on restflask.* to victor@'localhost' identified by 'victzzzz';' Y5 u( A  i2 z  o+ p0 x
Query OK, 0 rows affected (0.002 sec). U- e7 W+ W1 t5 s) P

# w$ y1 h  [1 ]) Q9 C; e* `  M6 ]* S5 `; c- Z( r% O7 b
; x  H) _1 A5 z& [
MariaDB [(none)]> create user victor@'%' identified by 'victxxxx;7 S# B3 I$ x% \3 c1 k" U" F3 \
Query OK, 0 rows affected (0.003 sec)
6 z1 q2 R4 n2 j0 ?% f1 Q; C( h( z8 r" N5 R8 V4 ~
MariaDB [(none)]> create user victor@'localhost' identified by 'victxxxx';% q2 a  X. V  I( l2 N8 `
Query OK, 0 rows affected (0.001 sec)6 L# l+ b, y5 {8 c1 [; q

8 v/ h7 s8 e% z8 p+ c3 Y! b, i- |1 l1 P7 R3 E! k' E, {4 }
( M1 a) l' d; G+ i- M$ o8 \

% P  S1 r% F' J8 V4 Y0 W: O- h( ?3 Z! M! D% A, @
7 y- w* C( W, n( P) {5 y
 楼主| 发表于 2024-7-23 15:44:09 | 显示全部楼层
MariaDB [(none)]> create database restflask ;
  W: C9 K2 c: H1 h% s! S# VQuery OK, 1 row affected (0.001 sec)
, h% d3 _  R5 T0 V% H1 G
 楼主| 发表于 2024-7-23 16:00:24 | 显示全部楼层
测试连接 带ip地址访问:5 s9 ]2 t1 C' f# [" c" ?' w7 i
mysql -u victor -p( s' ?& M. x8 }/ W2 {4 N
Enter password: ' Q2 g. E* N% D: F8 M* |
Welcome to the MariaDB monitor.  Commands end with ; or \g./ |0 ^) i* _) h# F9 z
Your MariaDB connection id is 16
# o, w! h/ \, V8 R# M9 MServer version: 10.5.22-MariaDB MariaDB Server# n& v2 w4 X, Q% E7 `7 k

# O0 c$ \* ]6 _Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
3 ]! L/ i3 C  |0 k3 r6 K; U/ f( p' K8 k3 [& F  ?& t
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.6 T1 E; O2 E" Q+ x% x

# x* K2 p7 p0 C9 J( ?MariaDB [(none)]> show databases;) w) B$ c6 n$ t9 g$ M7 m! L/ v1 Q
+--------------------+
' s! K' n9 @  `1 n# Z( I. c| Database           |
  n* ?7 h6 ^* S/ Z1 {* I+--------------------+* f- ~# ^; W) [" f! T8 O. G; X4 j
| information_schema |
7 X* S4 h+ G5 @1 z+ \6 ~6 v# O4 \7 i| restflask          |
8 [& i9 k/ u8 r% ?0 }( g5 y+--------------------+3 F( z! n5 D- L' n, z
2 rows in set (0.001 sec)7 c8 P) I- t$ T8 {, ?0 M
2 h; t4 f9 ^  |# \( V  e
MariaDB [(none)]> use restflask! y5 a" G. u0 i
Database changed6 `* v  |- ~# K$ q
MariaDB [restflask]> show tables;* e& S3 ~2 C- P- x
Empty set (0.000 sec)( C0 l3 `- D* L* l8 H1 f

! S2 A- @4 N4 _  _& l* ~MariaDB [restflask]> exit7 W2 d/ V7 i" h2 j; s* J  e
Bye% t, j# g0 Q# H: `& e( `
[root@python-flask mysqlclient-2.2.4]# mysql -u victor -p -h 192.168.13.131+ F7 _& W* T0 _9 L! P+ O
Enter password: " i6 j  @& O" g% K) d7 A
Welcome to the MariaDB monitor.  Commands end with ; or \g.. J8 e  d) X5 j/ E+ l, n5 n8 K
Your MariaDB connection id is 17
+ H! T3 l% T+ g0 c6 W2 z- VServer version: 10.5.22-MariaDB MariaDB Server' n$ w1 r8 B) P4 ]
% i/ ~; g8 h* [* o/ u
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
0 c8 H2 k% n6 F; h; p$ x! }0 _5 k: m. R! |( m( s0 D
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
0 H+ [! i2 H: E0 p( x+ u7 q# s' _8 R6 \* d) P2 G/ }* Z4 l; I
MariaDB [(none)]> exit
- O) M! {( O% n/ F0 [% ~- k9 OBye1 S# c# m% U/ H  D0 x' E
 楼主| 发表于 2024-7-25 07:18:15 | 显示全部楼层
MariaDB [(none)]>  create user victor@'%' identified by 'xxxx';% x$ H! {3 s) g# B
Query OK, 0 rows affected (0.004 sec)
3 ?$ x9 s1 Z  o9 l! ~0 C8 w
6 W' l# r: y9 K' ~4 ZMariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'%' identified by 'xxxx';
' P$ L0 K; E: |6 i5 |% ]Query OK, 0 rows affected (0.001 sec)
$ G2 ?* ~; ?+ Z9 b1 S  l2 O, \+ p) h; ]5 V( z
MariaDB [(none)]> grant ALL PRIVILEGES on testflask.* to victor@'localhost' identified by 'xxxx';' K. z* E% f/ @+ c4 E3 {3 b
Query OK, 0 rows affected (0.002 sec)- m" @0 c1 ]/ @1 O6 ~0 q
 楼主| 发表于 2024-7-27 00:12:19 | 显示全部楼层
MariaDB [(none)]> CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ ;
/ O$ U) l3 m# H: ~6 T) q- EQuery OK, 1 row affected (0.005 sec)
) l5 ^* `" H; x3 j
 楼主| 发表于 2024-7-30 22:54:02 | 显示全部楼层
MariaDB [(none)]> show create database testflask! P# M. W; E1 [( x
    -> ;
) Z( S2 j1 M, Z; q5 m9 b+-----------+--------------------------------------------------------------------------------------------------+
, u8 l1 _! Q9 W# S  h| Database  | Create Database                                                                                  |- a# U2 B* ], n1 P
+-----------+--------------------------------------------------------------------------------------------------+( N$ u) b  \- J
| testflask | CREATE DATABASE `testflask` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ |& w; N7 r- B5 t$ ]9 l( E# _. Q' l
+-----------+--------------------------------------------------------------------------------------------------+
' `/ F1 Z. v' t4 d% |9 K/ Y1 row in set (0.001 sec)
/ Q9 I2 c- Y7 f" c7 [
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-9 01:06 , Processed in 0.064072 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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