MYSQL入门

源码包可以在这个网址获得:
http://download.mysql.cn/src/2006/0208/62.html

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql --with-charset=gb2312

MySQL has a Web site at http://www.mysql.com/ which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.

Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.

Thank you for choosing MySQL!

>make
>make install
shell> bin/mysql -uroot -p
(输入密码,默认密码为空,直接回车即可)
遇到这样的问题,说明MYSQL还没有启动:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
这样办:
[root@ssss bin]# ./mysql_install_db --user=mysql
[root@ssss bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 1 to server version: 5.0.18-log

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql>

============================================
显示数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mytable            |
| mytestdb           |
| test               |
+--------------------+
5 rows in set (0.07 sec)
===========================================
创建数据库
mysql> create database test01db;
Query OK, 1 row affected (0.00 sec)

选择一个库进行后面的操作
mysql> use mytestdb
Database changed

查看当前操作的是哪个库
mysql> select database();
+------------+
| database() |
+------------+
| mytestdb   |
+------------+
1 row in set (0.00 sec)

创建一个表
mysql> create table attackip (dip varchar(64),dport int,remark varchar(64));
Query OK, 0 rows affected (0.04 sec)

mysql> show tables;
+--------------------+
| Tables_in_mytestdb |
+--------------------+
| attackip           |
+--------------------+
1 row in set (0.00 sec)

获得表结构
mysql> desc attackip;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| dip    | varchar(64) | YES  |     | NULL    |       |
| dport  | int(11)     | YES  |     | NULL    |       |
| remark | varchar(64) | YES  |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

更改表的结构
mysql> alter table attackip add column id int not null primary key auto_increment;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc attackip;                                                                      +--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| dip    | varchar(64) | YES  |     | NULL    |                |
| dport  | int(11)     | YES  |     | NULL    |                |
| remark | varchar(64) | YES  |     | NULL    |                |
| id     | int(11)     | NO   | PRI | NULL    | auto_increment |
+--------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

数据的增删改

增加in
mysql> insert into attackip values ('202.156.32.56',1433,'attackip',1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from attackip;
+---------------+-------+----------+----+
| dip           | dport | remark   | id |
+---------------+-------+----------+----+
| 202.156.32.56 |  1433 | attackip |  1 |
| 202.156.32.56 |    80 | attackip |  2 |
+---------------+-------+----------+----+
2 rows in set (0.01 sec)

删除
mysql> delete from attackip where id=1;
Query OK, 1 row affected (0.00 sec)

mysql> select * from attackip;
+---------------+-------+----------+----+
| dip           | dport | remark   | id |
+---------------+-------+----------+----+
| 202.156.32.56 |    80 | attackip |  2 |
+---------------+-------+----------+----+
1 row in set (0.00 sec)

修改
mysql> update attackip set dport=3389 where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from attackip;
+---------------+-------+----------+----+
| dip           | dport | remark   | id |
+---------------+-------+----------+----+
| 202.156.32.56 |  1433 | attackip |  1 |
| 202.156.32.56 |  3389 | attackip |  2 |
+---------------+-------+----------+----+
2 rows in set (0.00 sec)

=============================================
DBA,Database Administrator,数据库管理员
对于每一个应用,需要
DBA来创建数据库的存储结构TableSpaces
DBA来创建数据库对象Tables、Views、Indexes
根据各种反馈,DBA还需要
修改DB的结构
登记DB的用户、维护DB的安全性
保证DB的使用符合知识产权的相关法规
控制和监控用户对数据库的访问
监控和优化数据库的性能
制定数据库备份计划、灾难发生时对DB信息进行恢复
维护适当介质上的存档或者备份数据
备份和恢复数据库
联系数据库系统生产厂商,跟踪技术信息

因此,DBA必须具备:
自信心、好奇心、坚韧意志力、老练、自我驱动、注意细节
比如:数据字典Data Dictionary,管理工具Tools以及支持包Packages
要重视脚本Script,表大小Table Size、表空间使用Tablespace Usage等等。

DBA分等级:
初级Primary
中级Intermediate
高级Senior

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值