一、安装MYSQL软件
可以直接通过yum安装系统自带的版本5 mysql软件,当然也可以到http://www.mysql.org/下载安装.
然后通过service mysqld start
chkconfig mysqld on
开启服务...
二、设置数据库管理员密码和创建使用数据库
1、mysqladmin -u root password xxx
先给root用户创建密码,root是mysql的超级管理员
2、mysql -u root -p
[root@wzp ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.0.45 Source distribution
Type ''help;'' or ''h'' for help. Type ''c'' to clear the buffer.
mysql>
root管理员通过密码登陆mysql服务器
3、mysql命令
有两种:
分别是mysql命令和标准SQL语句
4、SHOW DATABASES;
mysql> show databases;
--------------------
| Database |
--------------------
| information_schema |
| mysql |
| test |
--------------------
3 rows in set (0.00 sec)
查看数据库和表
5、USE mysql;
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
连接数据库mysql
6、SHOW TABLES;
mysql> show tables;
---------------------------
| Tables_in_mysql |
---------------------------
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| proc |
| procs_priv |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
---------------------------
17 rows in set (0.00 sec)
查看表
7、CREATE DATABASE test;
SHOW DATABASES;
USE test;
SHOW TABLES;
创建数据库
8、mysql> create user 51cto identified by ''51cto''; //这里记得加上单引号,跟oracle下设置用户密码不一样.
创建用户账号,并且设置密码
9、mysql test -u test -p
通过新用户连接到数据库test上
OK,如上的九部就完成了数据库的创建和用户账号的创建工作.
三、创建管理表
然后进行处理表的工作:
1、
mysql> show tables;
Empty set (0.00 sec)
mysql> create table test
-> (id int,name varchar(10));
Query OK, 0 rows affected (0.05 sec)
mysql> desc test;
------- ------------- ------ ----- --------- -------
| Field | Type | Null | Key | Default | Extra |
------- ------------- ------ ----- --------- -------
| id | int(11) | YES | | NULL | |
| name | varchar(10) | YES | | NULL | |
------- ------------- ------ ----- --------- -------
2 rows in set (0.00 sec)
2、
mysql> insert into 51cto values(1,''51cto.com'');
Query OK, 1 row affected (0.00 sec)
mysql> insert into 51cto values(2,''163.com'');
Query OK, 1 row affected (0.00 sec)
mysql> insert into 51cto values(3,''qq.com'');
Query OK, 1 row affected (0.00 sec)
|