关闭

MYSQL入门

618人阅读 评论(0) 收藏 举报

源码包可以在这个网址获得:
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

0
0

猜你在找
【直播】机器学习&数据挖掘7周实训--韦玮
【套餐】系统集成项目管理工程师顺利通关--徐朋
【直播】3小时掌握Docker最佳实战-徐西宁
【套餐】机器学习系列套餐(算法+实战)--唐宇迪
【直播】计算机视觉原理及实战--屈教授
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之矩阵--黄博士
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之凸优化--马博士
【套餐】Javascript 设计模式实战--曾亮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:872次
    • 积分:24
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档
    阅读排行
    评论排行