MySQL数据库的初次使用
启动MySQL数据库:
\[z Act6K0
0p+U:p?VQ Dv0[root@zieckey root]# safe_mysqld -u mysql&PHPChina 开源社区门户0i @-x&Z)pB%KA@0@
[1] 5288PHPChina 开源社区门户s Q bt,?@]QEb
[root@zieckey root]# Starting mysqld daemon with databases from /var/lib/mysqlPHPChina 开源社区门户,f | uc#v%eF;t;y
PHPChina 开源社区门户 |:W9wJ{J
使用MySQL数据库:PHPChina 开源社区门户.GI7qL)@2i `m
[root@zieckey root]# mysql
8J3g$TY(Q)T1_0Welcome to the MySQL monitor. Commands end with ; or \g.
/P O3J W(JG W4Wr0Your MySQL connection id is 3 to server version: 3.23.54
x/p T*k^"aXf]0
-iu4b@opL7\0Type 'help;' or '\h' for help. Type '\c' to clear the buffer.PHPChina 开源社区门户:pl |j&o]
PHPChina 开源社区门户`6t7`'g3y%Mj#N
mysql>
C9Z:p5p eMa'f4\0
+Qyi0bh7q.^Si0创建一个数据库:
0O)fd9p }0mysql> create database testdb;
!G/XQAt/P0VH-kY0Query OK, 1 row affected (0.00 sec)
yhw%U v,x0
&ya"O;R$S01、显示数据库
pc#xC6d0 mysql> show databases;
&U@;Qd/_!p0 +----------+PHPChina 开源社区门户9x5L6D$Ayz6b
| Database |PHPChina 开源社区门户&O1JQ.Q-n3O
+----------+PHPChina 开源社区门户"a{x*H3a\/n\BX%k
| mysql |PHPChina 开源社区门户(S&R`E.l%{FL
| test |
Fo9hkUOe0_i\&z0 +----------+
Ap A YO7gd}0 2 rows in set (0.04 sec)PHPChina 开源社区门户 ^6zj0? mJF,E.x
PHPChina 开源社区门户/D#D4wqn ?a,MV3U0n
Mysql刚安装完有两个数据库:mysql和test。mysql库非常重要,它里面有MySQL的系统信息,我们改密码PHPChina 开源社区门户K3RQ;qu@^Ekp
PHPChina 开源社区门户M0Wf)J f0Q
和新增用户,实际上就是用这个库中的相关表进行操作。PHPChina 开源社区门户8EbJh9{'^oa
PHPChina 开源社区门户!y$l7lt}uY
2、显示数据库中的表
{Y~.y0I:w%Q0p0 mysql> use mysql; (打开库,对每个库进行操作就要打开此库,类似于foxpro )PHPChina 开源社区门户/P5aWE%amz
Database changed
h4I8GEw0PHPChina 开源社区门户,MIs4S/aF w#U5AU.l
mysql> show tables;PHPChina 开源社区门户%_kN5aXTyH3o
+-----------------+
6P%N9I-Ua0shdP0 | Tables_in_mysql |
Ig0S'C)OSy0 +-----------------+PHPChina 开源社区门户3s'v!|E4r `vy^
| columns_priv |PHPChina 开源社区门户'x h:yi E5\{V%ZM+[,V
| db |PHPChina 开源社区门户3[i |L*H|.B0~
| func |PHPChina 开源社区门户)k&@'G? QZ3r;WX
| host |PHPChina 开源社区门户o5RI/zvo#i
| tables_priv |PHPChina 开源社区门户?8_e`KP O
| user |
_'I)X$t0lZ*J"mO0 +-----------------+PHPChina 开源社区门户^#fJkou&c1k'\!?
6 rows in set (0.01 sec)
\[z Act6K0
0p+U:p?VQ Dv0[root@zieckey root]# safe_mysqld -u mysql&PHPChina 开源社区门户0i @-x&Z)pB%KA@0@
[1] 5288PHPChina 开源社区门户s Q bt,?@]QEb
[root@zieckey root]# Starting mysqld daemon with databases from /var/lib/mysqlPHPChina 开源社区门户,f | uc#v%eF;t;y
PHPChina 开源社区门户 |:W9wJ{J
使用MySQL数据库:PHPChina 开源社区门户.GI7qL)@2i `m
[root@zieckey root]# mysql
8J3g$TY(Q)T1_0Welcome to the MySQL monitor. Commands end with ; or \g.
/P O3J W(JG W4Wr0Your MySQL connection id is 3 to server version: 3.23.54
x/p T*k^"aXf]0
-iu4b@opL7\0Type 'help;' or '\h' for help. Type '\c' to clear the buffer.PHPChina 开源社区门户:pl |j&o]
PHPChina 开源社区门户`6t7`'g3y%Mj#N
mysql>
C9Z:p5p eMa'f4\0
+Qyi0bh7q.^Si0创建一个数据库:
0O)fd9p }0mysql> create database testdb;
!G/XQAt/P0VH-kY0Query OK, 1 row affected (0.00 sec)
yhw%U v,x0
&ya"O;R$S01、显示数据库
pc#xC6d0 mysql> show databases;
&U@;Qd/_!p0 +----------+PHPChina 开源社区门户9x5L6D$Ayz6b
| Database |PHPChina 开源社区门户&O1JQ.Q-n3O
+----------+PHPChina 开源社区门户"a{x*H3a\/n\BX%k
| mysql |PHPChina 开源社区门户(S&R`E.l%{FL
| test |
Fo9hkUOe0_i\&z0 +----------+
Ap A YO7gd}0 2 rows in set (0.04 sec)PHPChina 开源社区门户 ^6zj0? mJF,E.x
PHPChina 开源社区门户/D#D4wqn ?a,MV3U0n
Mysql刚安装完有两个数据库:mysql和test。mysql库非常重要,它里面有MySQL的系统信息,我们改密码PHPChina 开源社区门户K3RQ;qu@^Ekp
PHPChina 开源社区门户M0Wf)J f0Q
和新增用户,实际上就是用这个库中的相关表进行操作。PHPChina 开源社区门户8EbJh9{'^oa
PHPChina 开源社区门户!y$l7lt}uY
2、显示数据库中的表
{Y~.y0I:w%Q0p0 mysql> use mysql; (打开库,对每个库进行操作就要打开此库,类似于foxpro )PHPChina 开源社区门户/P5aWE%amz
Database changed
h4I8GEw0PHPChina 开源社区门户,MIs4S/aF w#U5AU.l
mysql> show tables;PHPChina 开源社区门户%_kN5aXTyH3o
+-----------------+
6P%N9I-Ua0shdP0 | Tables_in_mysql |
Ig0S'C)OSy0 +-----------------+PHPChina 开源社区门户3s'v!|E4r `vy^
| columns_priv |PHPChina 开源社区门户'x h:yi E5\{V%ZM+[,V
| db |PHPChina 开源社区门户3[i |L*H|.B0~
| func |PHPChina 开源社区门户)k&@'G? QZ3r;WX
| host |PHPChina 开源社区门户o5RI/zvo#i
| tables_priv |PHPChina 开源社区门户?8_e`KP O
| user |
_'I)X$t0lZ*J"mO0 +-----------------+PHPChina 开源社区门户^#fJkou&c1k'\!?
6 rows in set (0.01 sec)