RedHat下MySQL的基本使用方法分享
发布时间:2024-01-18 06:00:16
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)
猜你喜欢
- 引言skimage提供了io模块,顾名思义,这个模块是用来图片输入输出操作的。为了方便练习,也提供一个data模块,里面嵌套了一些示例图片,
- 前言本文将给大家简单介绍关于区块链(BlockChain)的相关知识,并用Python做一简单实现。下面话不多说,来一起看看详细的介绍:什么
- 1、django应用Celerydjango框架请求/响应的过程是同步的,框架本身无法实现异步响应。但是我们在项目过程中会经常会遇到一些耗时
- 背景今天有人问我 “为什么数据库中有人推荐使用 int 类型来保存 IP 地址?”。现在(2020年)来看这个东西已经有点过时了,一方面是磁
- 本文实例讲述了Python实现破解12306图片验证码的方法。分享给大家供大家参考,具体如下:不知从何时起,12306的登录验证码竟然变成了
- 一、基础概述机器学习(Machine Learing)是一门多领域交叉学科,涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科。机
- cv2库在opencv库内,因此需要下载opencv-python1、打开windows命令行:win+Rcmd2、更新pip版本(不一定要
- SQL Server数据库操作中,在2005以上的版本新增加了一个APPLY表运算符的功能。新增的APPLY表运算符把右表表达式应用到左表表
- 有时需要根据项目的实际需求向spider传递参数以控制spider的行为,比如说,根据用户提交的url来控制spider爬取的网站。在这种情
- 代码如下,U我认为对于新手来说最重要的是学会rnn读取数据的格式。# -*- coding: utf-8 -*-""&q
- GetRows 方法 将 Recordset 对象的多个记录复制到数组中。 语法 代码如下: array = recordset.GetR
- 在windows平台上使用pyhton编写语音识别程序需要用到speech模块,speech模块支持的主要功能有:文本合成语音,将键盘输入的
- 简单的仿图片验证码,适合新手简单的仿图片验证码演示,很容易被破解,实用性不大,但拿出来给新手学习一下还是不错的:JScript.Asp代码示
- 记录下Django关于日期的配置,以及如何根据日期滚动切割日志的问题。配置的源码在githun上 https://github.com/bl
- 前言:Python 面向对象的高级编程语言,以其语法简单、免费开源、免编译扩展性高,同时也可以嵌入到C/C++程序和丰富的第三方
- IIS上设置301 跳转相信大家都会,只要在网站-属性-主目录里 选择重定向URL就行了,这样整站就跳转到目标站点了,但是有个问
- 举个例子来说,要查找出2007-10-12至2007-10-31之间在网站上注册的会员,选择好日期后,点击“查询”按钮,发现2007-10-
- 本文实例讲述了Python对列表排序的方法。分享给大家供大家参考。具体分析如下:1、sort()函数sort()函数使用固定的排序算法对列表
- 1、使用mysqldump工具将MySql数据库备份mysqldump -u root -p -c --default-character-
- 在做项目的过程中,我们经常会建立各种各样的规范,以方便团队之间更好的合作更好的完成项目;同样我们也经常会听到各种各样的协议,比如Google