RedHat下MySQL的基本使用方法分享
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)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/3407/viewspace-2803815/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- redhat AS4 下MYSQL 5.0的安裝RedhatMySql
- docker的基本使用方法Docker
- Vue元件的基本使用方法Vue元件
- redhat 5.4下安裝MYSQL全過程RedhatMySql
- RedHat5下安裝Mysql詳解RedhatMySql
- MySQL中的alter table命令的基本使用方法及提速最佳化MySql
- Fastjson的基本使用方法大全ASTJSON
- Centos7或RedHat7下安裝MysqlCentOSRedhatMySql
- redhat linux系統下檢視Emulex HBA卡基本命令RedhatLinux
- ubuntu vi/vim 基本使用方法Ubuntu
- 四種XML操作方式的基本使用方法XML
- RedHat AS4-U2下Mysql 5.0.22叢集配置RedhatMySql
- RedHat 7.2配置LAMP環境下的redius+mysql+openvpn環境RedhatLAMPMySql
- AIX 下的基本管理 (一) :使用者和組的管理 分享AI
- redhat 下載地址Redhat
- 【除錯】ftrace(一)基本使用方法除錯
- ESC快捷鍵使用方法分享
- 【Mysql 學習】perror的使用方法MySqlError
- MySQL的基本概述MySql
- MySQL的基本操作MySql
- 技術分享 | ProxySQL 搭配 MySQL HA (下)MySql
- mysql & oracle savepoint 使用方法MySqlOracle
- PHP中基本符號及使用方法PHP符號
- 啟動mysql時報錯的解決(mysql 5.0.45 redhat as 43)MySqlRedhat
- 在RedHat Linux 7.3下安裝Apache + PHP + Mysql + JDK + Resin (轉)RedhatLinuxApachePHPMySqlJDK
- 最簡單mysql的使用方法(轉)MySql
- Mac環境下MySQL的安裝和基本命令的使用MacMySql
- db2 在redhat下的配置DB2Redhat
- 分享基本golang學習的書Golang
- MySQL Cluster install on Redhat7MySqlRedhat
- redhat 5.5 配置 mysql AB複製RedhatMySql
- (轉)redhat下安裝oracle,設定redhat核心引數RedhatOracle
- redhat下如何編譯bbed!Redhat編譯
- Redhat下dd命令測試Redhat
- 在RedHat下建立群集Redhat
- redhat9.0下載地址Redhat
- Redhat8下XMMS的除錯(轉)Redhat除錯
- MySQL基本使用MySql