香港云主机最佳企业级服务商!

ADSL拨号VPS包含了中国大陆(联通,移动,电信,)

中国香港,国外拨号VPS。

当前位置:云主机 > MYSQL >

电信ADSL拨号VPS
联通ADSL拨号VPS
移动ADSL拨号VPS

RedHat下MySQL的基本使用方法分享


时间:2020-11-02 13:28 作者:admin610456


1. 下载RPM安装包, 因为安装mysql/' target='_blank'>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)

(责任编辑:admin)






帮助中心
会员注册
找回密码
新闻中心
快捷通道
域名登录面板
虚机登录面板
云主机登录面板
关于我们
关于我们
联系我们
联系方式

售前咨询:17830004266(重庆移动)

企业QQ:383546523

《中华人民共和国工业和信息化部》 编号:ICP备00012341号

Copyright © 2002 -2018 香港云主机 版权所有
声明:香港云主机品牌标志、品牌吉祥物均已注册商标,版权所有,窃用必究

云官方微信

在线客服

  • 企业QQ: 点击这里给我发消息
  • 技术支持:383546523

  • 公司总台电话:17830004266(重庆移动)
  • 售前咨询热线:17830004266(重庆移动)