1. 下载RPM安装包, 因为安装MySQL的时候,软件会需要一依赖关系, 所以建议把所有的安装包下载下载, 再依次安装所以的RPM包。

2. 在RedHat下安装后, root密码为空, 设置MySQL的 root密码, 用下面的命令来设置.

[nb@SIT ~]$ mysql -u root -p[newpassword]
3. 修改MySQL的root 密码, 用下面 的命令:

[nb@SIT ~]$ mysqladmin -u root -p[oldpasswrod] password[newpassword]
4. 用root登录MySQL, 输入下面的命令, 再输入密码, 就可以以root的身份登录到MySQL

[nb@SIT ~]$ mysql -u root -p
Enter password:
5. 出现下面的字符, 就表示成功登录到了MySQL,

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.5.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
6. 显示当前已经存在的数据库,输入: show databases;

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
7. 创建一个新的数据库, 输入: create database [name];

mysql> create database mytest;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mytest |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
8. 删除一个已经存在的数据库, 输入: drop database [name];

mysql> drop database mytest;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
9. 创建一张表, 输入: create table [name] [option...]
显示表的内容: describe [table name];

mysql> create table device
-> (
-> id int,
-> pn varchar(8),
-> descript varchar(30)
-> );
Query OK, 0 rows affected (0.01 sec)

mysql> describe device;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| pn | varchar(8) | YES | | NULL | |
| descript | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
10. 向表里面添加数据, 输入: insert into [table_name] set option1=[value], option2=[value] ...

mysql> insert into device set id=1,pn="abcd",descript="this is a good device";
Query OK, 1 row affected (0.01 sec)

mysql> insert into device set id=2,pn="efgh",descript="this is a good device";
Query OK, 1 row affected (0.00 sec)
11. 查看表里面的内容, 输入: select [col_name] from [table_name]

mysql> select * from device;
+------+------+-----------------------+
| id | pn | descript |
+------+------+-----------------------+
| 1 | abcd | this is a good device |
| 2 | efgh | this is a good device |
+------+------+-----------------------+
2 rows in set (0.01 sec)
12. 选择性的查询表里的内容, * 是通配符, 表示所有的, 查询单项的时候, 输入: select * from [table_name] where opiont=[value];

mysql> select * from device where id=2;
+------+------+-----------------------+
| id | pn | descript |
+------+------+-----------------------+
| 2 | efgh | this is a good device |
+------+------+-----------------------+
1 row in set (0.00 sec)
13. 选择性查询表里的内容, 输入: select [option]...[option] from [table_name] where [option]=[value];

mysql> select id,descript from device where id=2;
+------+-----------------------+
| id | descript |
+------+-----------------------+
| 2 | this is a good device |
+------+-----------------------+
1 row in set (0.00 sec)

标签:
MySQL

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com

评论“RedHat下MySQL的基本使用方法分享”

暂无“RedHat下MySQL的基本使用方法分享”评论...

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?