日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql用com_MySQL 使用教程

發布時間:2023/12/2 数据库 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql用com_MySQL 使用教程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

關于 MySQL

MySQL 是最流行的開源數據庫。

本文簡明的講解了 MySQL 如何下載安裝到使用的整個過程。

MySQL 支持多種特性:

使用 C和 C++編寫,并使用了多種編譯器進行測試,保證了源代碼的可移植性。

支持 AIX、FreeBSD、HP-UX、Linux、Mac OS、NovellNetware、OpenBSD、OS/2 Wrap、Solaris、Windows等多種操作系統。

為多種編程語言提供了 API。這些編程語言包括 C、C++、Python、Java、Perl、PHP、Eiffel、Ruby,.NET和 Tcl 等。支持多線程,充分利用 CPU 資源。

優化的 SQL查詢算法,有效地提高查詢速度。

既能夠作為一個單獨的應用程序應用在客戶端服務器網絡環境中,也能夠作為一個庫而嵌入到其他的軟件中。

提供多語言支持,常見的編碼如中文的 GB 2312、BIG5,日文的 Shift_JIS等都可以用作數據表名和數據列名。

提供 TCP/IP、ODBC 和 JDBC等多種數據庫連接途徑。

提供用于管理、檢查、優化數據庫操作的管理工具。

支持大型的數據庫。可以處理擁有上千萬條記錄的大型數據庫。

支持多種存儲引擎。

MySQL 是開源的,所以你不需要支付額外的費用。

MySQL 使用標準的 SQL數據語言形式。

MySQL 對 PHP 有很好的支持,PHP是目前最流行的 Web 開發語言。

MySQL是可以定制的,采用了 GPL協議,你可以修改源碼來開發自己的 MySQL 系統。

在線 DDL/更改功能,數據架構支持動態應用程序和開發人員靈活性(5.6[3] 新增)

復制全局事務標識,可支持自我修復式集群(5.6[3] 新增)

復制無崩潰從機,可提高可用性(5.6[3] 新增)

復制多線程從機,可提高性能(5.6[3] 新增)

下載、安裝

本例用的是 MySQL Community Edition (GPL) 版本,開源免費。

版本號:MySQL Community Server 5.6.24

平臺類型: Windows

安裝方式,可以選擇 MySQL Installer MSI 或者是 編譯壓縮包(形如 mysql-5.6.26-win32.zip 或 mysql-5.6.26-winx64.zip)。

下載完成后,解壓到放到任意目錄,本例為 C:\mysql 目錄

設置環境變量

放到 Path 變量下增加 ,C:\mysql\bin

配置

復制安裝目錄下的 my-default.ini 并重命名為 my.ini ,修改為

[mysqld]

basedir=C:/mysql

datadir=D:/MysqlData/data

basedir 為 mysql 安裝目錄。datadir 為數據存放目錄

安裝服務

安裝作為 Windows 服務。

MySQL 會隨著 Windows 的啟動和關閉而啟動和關閉

mysqld –install

C:\Users\Administrator.USER-20150424OX>mysqld –install

Service successfully installed.

其他可選的有:設置為手動啟動或者關閉服務

mysqld –install-manual

移除服務

mysqld –remove

啟動、關閉服務

啟動

NET START MySQL

C:\Users\Administrator.USER-20150424OX>NET START MySQL

MySQL 服務正在啟動 .

MySQL 服務已經啟動成功。

關閉

NET STOP MySQL

C:\Users\Administrator.USER-20150424OX>NET STOP MySQL

MySQL 服務正在停止.

MySQL 服務已成功停止。

測試安裝是否成功

mysqlshow

C:\Users\Administrator.USER-20150424OX>mysqlshow

+--------------------+

| Databases |

+--------------------+

| information_schema |

| test |

+--------------------+

mysqlshow -u root mysql

C:\Users\Administrator.USER-20150424OX>mysqlshow -u root mysql

Database: mysql

+---------------------------+

| Tables |

+---------------------------+

| columns_priv |

| db |

| event |

| func |

| general_log |

| help_category |

| help_keyword |

| help_relation |

| help_topic |

| innodb_index_stats |

| innodb_table_stats |

| ndb_binlog_index |

| plugin |

| proc |

| procs_priv |

| proxies_priv |

| servers |

| slave_master_info |

| slave_relay_log_info |

| slave_worker_info |

| slow_log |

| tables_priv |

| time_zone |

| time_zone_leap_second |

| time_zone_name |

| time_zone_transition |

| time_zone_transition_type |

| user |

+---------------------------+

mysqladmin version status proc

C:\Users\Administrator.USER-20150424OX>mysqladmin version status proc

mysqladmin Ver 8.42 Distrib 5.6.24, for Win64 on x86_64

Copyright (c) 2000, 2015, 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.

Server version 5.6.24

Protocol version 10

Connection localhost via TCP/IP

TCP port 3306

Uptime: 9 min 12 sec

Threads: 1 Questions: 7 Slow queries: 0 Opens: 67 Flush tables: 1 Open tabl

es: 60 Queries per second avg: 0.012

Uptime: 552 Threads: 1 Questions: 8 Slow queries: 0 Opens: 67 Flush tables:

1 Open tables: 60 Queries per second avg: 0.014

mysqladmin: process list failed; error: ‘Access denied; you need (at least one o

f) the PROCESS privilege(s) for this operation‘

mysql test

C:\Users\Administrator.USER-20150424OX>mysql test

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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 –help

連接到服務器,其中 host 是服務器IP, user 是用戶名

mysql -h host -u user -p

如果服務器在本地 ,

mysql -u user –p

提示輸入密碼,驗證通過后,如下

C:\Users\Administrator.USER-20150424OX>mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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>

斷開與服務器的鏈接

QUIT

mysql> QUIT

Bye

查詢(命令語句是不區分大小寫)

mysql> SELECT VERSION(), CURRENT_DATE;

+-----------+--------------+

| VERSION() | CURRENT_DATE |

+-----------+--------------+

| 5.6.24 | 2015-05-10 |

+-----------+--------------+

1 row in set (0.01 sec)

列出所有數據庫

mysql> SHOW DATABASES;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.00 sec)

創建一個自己的數據庫 menagerie

mysql> CREATE DATABASE menagerie;

Query OK, 1 row affected (0.03 sec)

給自己授予管理員權限

GRANT ALL ON menagerie.* TO ‘your_mysql_name‘@‘your_client_host‘;

訪問數據庫 menagerie

mysql> USE menagerie

Database changed

列出數據庫表

mysql> SHOW TABLES;

Empty set (0.00 sec)

創建表 pet

mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),

-> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);

Query OK, 0 rows affected (0.43 sec)

查看 pet 表的詳情

mysql> DESCRIBE pet;

+---------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------+-------------+------+-----+---------+-------+

| name | varchar(20) | YES | | NULL | |

| owner | varchar(20) | YES | | NULL | |

| species | varchar(20) | YES | | NULL | |

| sex | char(1) | YES | | NULL | |

| birth | date | YES | | NULL | |

| death | date | YES | | NULL | |

+---------+-------------+------+-----+---------+-------+

6 rows in set (0.01 sec)

插入數據

mysql> INSERT INTO pet

-> VALUES (‘Puffball‘,‘Diane‘,‘hamster‘,‘f‘,‘1999-03-30‘,NULL);

Query OK, 1 row affected (0.04 sec)

查詢所有的數據

mysql> SELECT * FROM pet;

+----------+-------+---------+------+------------+-------+

| name | owner | species | sex | birth | death |

+----------+-------+---------+------+------------+-------+

| Puffball | Diane | hamster | f | 1999-03-30 | NULL |

+----------+-------+---------+------+------------+-------+

1 row in set (0.00 sec)

修改數據

mysql> UPDATE pet SET birth = ‘1989-08-31‘ WHERE name = ‘Puffball‘;

Query OK, 1 row affected (0.11 sec)

Rows matched: 1 Changed: 1 Warnings: 0

刪除數據

mysql> DELETE FROM pet;

Query OK, 1 row affected (0.04 sec)

參考

原文:http://my.oschina.net/waylau/blog/413904

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的mysql用com_MySQL 使用教程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。