• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴(yán)以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            MySQL簡單使用

            轉(zhuǎn)載自:https://www-900.ibm.com/cn/support/viewdoc/detail?DocId=2011073000000

            MySQL簡單使用

            MySQL簡單使用
            MySQL最初廣泛地使用在Linux系統(tǒng),隨著MySQL的普及,在一些主流的UNIX系統(tǒng)中,如AIX,Solaris,也逐漸的多了起來,這篇文章將介紹如何在AIX平臺上使用MySQL數(shù)據(jù)庫。在以下的內(nèi)容中將按照數(shù)據(jù)庫初始化、數(shù)據(jù)庫管理、操作三個方面介紹。
            在介紹以下內(nèi)容之前,應(yīng)當(dāng)先清楚的知道MySQL分布,這里說的分布是指缺省情況下的安裝配置,其系統(tǒng)文件、數(shù)據(jù)文件、頭文件及提供的庫文件分布如下:
            系統(tǒng)文件: /usr/local/bin
            頭文件: /usr/local/include/mysql
            庫文件: /usr/local/lib/mysql
            數(shù)據(jù)庫文件:/var/mysql,按創(chuàng)建的數(shù)據(jù)庫名稱安樹狀結(jié)構(gòu)分布

            數(shù)據(jù)庫初始化
            通常情況下,MySQL初次安張結(jié)束后,如果直接運(yùn)行mysql連結(jié)MySQL數(shù)據(jù)庫服務(wù)器,會出
            現(xiàn)這樣的錯誤,Can't start server: Bind on TCP/IP port: Address already in use或者Can't start server : Bind on unix socket
            直觀的來看象是端口被占用的問題,實(shí)際上是MySQL未初始化引起的。對MySQL的初始化可通過運(yùn)行mysql_install_db來實(shí)現(xiàn),其輸出結(jié)果如下:
            [root@ibmp630/usr/local/bin#]./mysql_install_db
            Preparing db table
            Preparing host table
            Preparing user table
            Preparing func table
            Preparing tables_priv table
            Preparing columns_priv table
            Installing all prepared tables

            To start mysqld at boot time you have to copy support-files/mysql.server
            to the right place for your system

            PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
            This is done with:
            /usr/local/bin/mysqladmin -u root -p password 'new-password'
            /usr/local/bin/mysqladmin -u root -h ibmp630 -p password 'new-password'
            See the manual for more instructions.

            You can start the MySQL daemon with:
            cd /usr/local ; /usr/local/bin/safe_mysqld &
            You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
            cd sql-bench ; run-all-tests

            Please report any problems with the /usr/local/bin/mysqlbug script!

            The latest information about MySQL is available on the web at
            http://www.mysql.com
            Support MySQL by buying support/licenses at https://order.mysql.com

            從上面的輸出信息可以看出,mysql_install_db實(shí)際上是創(chuàng)建MySQL的權(quán)限信息,mysql_install_db并不覆蓋已經(jīng)存在的權(quán)限信息表,一般情況下,mysql_install_db只是在MySQL安裝完成后運(yùn)行一次既可。

            啟動停止數(shù)據(jù)庫
            數(shù)據(jù)庫的啟動和停止是最基本的操作,可以通過mysql.server和safe_mysqld啟動和停止MySQL。具體的操作方式為:
            1) 利用mysql.server,位置/usr/local/share/mysql
            啟動數(shù)據(jù)庫服務(wù)器:
            mysql.server start
            停止數(shù)據(jù)庫服務(wù)器:
            mysql.server stop
            實(shí)際上,mysql.server啟動服務(wù)器是通過safe_mysqld實(shí)現(xiàn)的。
            2) safe_mysqld
            safe_mysqld啟動服務(wù)器,不需要帶任何參數(shù),如下:
            safe_mysqld &
            停止數(shù)據(jù)庫,可以利用mysqladmin實(shí)現(xiàn),如下:
            mysqladmin shutdown

            數(shù)據(jù)庫管理
            對一些商業(yè)性的數(shù)據(jù)庫管理系統(tǒng),數(shù)據(jù)庫的管理是一個復(fù)雜的問題,如用戶管理、數(shù)據(jù)管理、表管理、系統(tǒng)優(yōu)化等等,MySQL數(shù)據(jù)庫系統(tǒng)也存在同樣的問題。這里只介紹mysqladmin和mysql兩個基本的工具,更詳細(xì)的操作請參考MySQL操作手冊。
            mysqladmin是最基本、常用的工具,如創(chuàng)建、刪除數(shù)據(jù)庫,修改用戶密碼,查看數(shù)據(jù)庫狀態(tài)等,mysqladmin常用的命令參數(shù)為:
            create databasename --:創(chuàng)建數(shù)據(jù)庫
            drop databasename ----:刪除數(shù)據(jù)庫及其所有相關(guān)的表
            extended-status ------:獲取MySQL服務(wù)器的詳細(xì)狀態(tài)
            kill id,id,... -------:殺掉MySQL的線程
            password new-password :修改用戶密碼
            ping -----------------:查看MySQL后臺進(jìn)程是否存在
            processlist ----------:顯示當(dāng)前的服務(wù)器的線程
            shutdown -------------:停止數(shù)據(jù)庫服務(wù)器
            status ---------------:獲取MySQL服務(wù)器狀態(tài)
            version --------------:查看MySQL服務(wù)器版本信息

            舉幾個簡單的例子,如下:
            1)修改MySQL用戶root的密碼為test,操作命令為:
            [root@ibmp630/usr/local/bin#]mysqladmin -u root -p password 'test'
            Enter password: <=== 輸入舊的用戶密碼
            2) 查看服務(wù)器的運(yùn)行狀態(tài)
            命令為:mysqladmin processlist status,例如:
            [root@ibmp630/usr/local/share/mysql#]mysqladmin -h ibmp630 proc stat
            +----+------+------+----+---------+------+-------+--------+
            | Id | User | Host | db | Command | Time | State | Info |
            +----+------+---------+----+---------+------+-------+-----+
            | 2 | root | ibmp630 | | Query | 0 | | show processlist |
            +----+------+---------+----+---------+------+-------+-----+
            Uptime: 39 Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1
            Open tables: 0 Queries per second avg: 0.051

            要介紹的第二個工具為msql,這是MySQL客戶端連結(jié)到服務(wù)器端的一個重要工具,通過它,我們可以得到一些更詳細(xì)的數(shù)據(jù)庫信息,完成對數(shù)據(jù)庫的操作,使用方法為:
            mysql –u user –p password
            正確連結(jié)到服務(wù)器系統(tǒng)將顯示如下提示符:
            mysql>

            簡單介紹在mysql工具中常用幾條命令,另外SQL語句的操作也是在mysql下完成的,對于SQL的操作,不再在此詳細(xì)描述,請參考相關(guān)的手冊。
            1)查看MySQL數(shù)據(jù)庫
            show databases; 例如:
            mysql> show databases;
            +----------+
            | Database |
            +----------+
            | mysql |
            | test |
            | testdb |
            +----------+
            3 rows in set (0.00 sec)

            2)查看當(dāng)前的數(shù)據(jù)庫
            select database(); 例如:
            mysql> select database();
            +------------+
            | database() |
            +------------+
            | testdb |
            +------------+
            1 row in set (0.06 sec)

            3) 打開并使用數(shù)據(jù)庫
            use database_name; 例如:
            mysql> use testdb;
            Reading table information for completion of table and column names
            You can turn off this feature to get a quicker startup with -A

            Database changed

            4) 查看表信息
            show tables;
            mysql> show tables;
            +------------------+
            | Tables_in_testdb |
            +------------------+
            | testtb |
            +------------------+
            1 row in set (0.00 sec)

            5) 查看表的結(jié)構(gòu)信息
            desc table_name
            mysql> desc db;
            +---------------+---------------+----+---+-------+-----+
            | Field --------| Type ---------|Null|Key|Default|Extra|
            +---------------+---------------+----+---+-------+-----+
            |Host ----------|char(60) binary| ---|PRI| ------| ----|
            |Db ------------|char(64) binary| ---|PRI| ------| ----|
            |User ----------|char(16) binary| ---|PRI| ------|---- |
            |Select_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Insert_priv----|enum('N','Y') -| ---| --| N ----|---- |
            |Update_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Delete_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Create_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Drop_priv -----|enum('N','Y') -| ---| --| N ----| ----|
            |Grant_priv ----|enum('N','Y') -| ---|-- | N ----| ----|
            |References_priv|enum('N','Y') -| ---|-- | N ----| ----|
            |Index_priv ----|enum('N','Y') -| ---| --| N ----|---- |
            |Alter_priv ----|enum('N','Y') -| ---| --| N ----| ----|
            +---------------+---------------+----+---+-------+-----+
            13 rows in set (0.00 sec)

            以上給出的知識MySQL的一些基本知識,這篇文章的目的是希望讀者看完后能基本操作
            MySQL數(shù)據(jù)庫,更完整的信息請參考MySQL的使用手冊。

            MySQL簡單使用
            MySQL最初廣泛地使用在Linux系統(tǒng),隨著MySQL的普及,在一些主流的UNIX系統(tǒng)中,如AIX,Solaris,也逐漸的多了起來,這篇文章將介紹如何在AIX平臺上使用MySQL數(shù)據(jù)庫。在以下的內(nèi)容中將按照數(shù)據(jù)庫初始化、數(shù)據(jù)庫管理、操作三個方面介紹。
            在介紹以下內(nèi)容之前,應(yīng)當(dāng)先清楚的知道MySQL分布,這里說的分布是指缺省情況下的安裝配置,其系統(tǒng)文件、數(shù)據(jù)文件、頭文件及提供的庫文件分布如下:
            系統(tǒng)文件: /usr/local/bin
            頭文件: /usr/local/include/mysql
            庫文件: /usr/local/lib/mysql
            數(shù)據(jù)庫文件:/var/mysql,按創(chuàng)建的數(shù)據(jù)庫名稱安樹狀結(jié)構(gòu)分布

            數(shù)據(jù)庫初始化
            通常情況下,MySQL初次安張結(jié)束后,如果直接運(yùn)行mysql連結(jié)MySQL數(shù)據(jù)庫服務(wù)器,會出
            現(xiàn)這樣的錯誤,Can't start server: Bind on TCP/IP port: Address already in use或者Can't start server : Bind on unix socket
            直觀的來看象是端口被占用的問題,實(shí)際上是MySQL未初始化引起的。對MySQL的初始化可通過運(yùn)行mysql_install_db來實(shí)現(xiàn),其輸出結(jié)果如下:
            [root@ibmp630/usr/local/bin#]./mysql_install_db
            Preparing db table
            Preparing host table
            Preparing user table
            Preparing func table
            Preparing tables_priv table
            Preparing columns_priv table
            Installing all prepared tables

            To start mysqld at boot time you have to copy support-files/mysql.server
            to the right place for your system

            PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
            This is done with:
            /usr/local/bin/mysqladmin -u root -p password 'new-password'
            /usr/local/bin/mysqladmin -u root -h ibmp630 -p password 'new-password'
            See the manual for more instructions.

            You can start the MySQL daemon with:
            cd /usr/local ; /usr/local/bin/safe_mysqld &
            You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
            cd sql-bench ; run-all-tests

            Please report any problems with the /usr/local/bin/mysqlbug script!

            The latest information about MySQL is available on the web at
            http://www.mysql.com
            Support MySQL by buying support/licenses at https://order.mysql.com

            從上面的輸出信息可以看出,mysql_install_db實(shí)際上是創(chuàng)建MySQL的權(quán)限信息,mysql_install_db并不覆蓋已經(jīng)存在的權(quán)限信息表,一般情況下,mysql_install_db只是在MySQL安裝完成后運(yùn)行一次既可。

            啟動停止數(shù)據(jù)庫
            數(shù)據(jù)庫的啟動和停止是最基本的操作,可以通過mysql.server和safe_mysqld啟動和停止MySQL。具體的操作方式為:
            1) 利用mysql.server,位置/usr/local/share/mysql
            啟動數(shù)據(jù)庫服務(wù)器:
            mysql.server start
            停止數(shù)據(jù)庫服務(wù)器:
            mysql.server stop
            實(shí)際上,mysql.server啟動服務(wù)器是通過safe_mysqld實(shí)現(xiàn)的。
            2) safe_mysqld
            safe_mysqld啟動服務(wù)器,不需要帶任何參數(shù),如下:
            safe_mysqld &
            停止數(shù)據(jù)庫,可以利用mysqladmin實(shí)現(xiàn),如下:
            mysqladmin shutdown

            數(shù)據(jù)庫管理
            對一些商業(yè)性的數(shù)據(jù)庫管理系統(tǒng),數(shù)據(jù)庫的管理是一個復(fù)雜的問題,如用戶管理、數(shù)據(jù)管理、表管理、系統(tǒng)優(yōu)化等等,MySQL數(shù)據(jù)庫系統(tǒng)也存在同樣的問題。這里只介紹mysqladmin和mysql兩個基本的工具,更詳細(xì)的操作請參考MySQL操作手冊。
            mysqladmin是最基本、常用的工具,如創(chuàng)建、刪除數(shù)據(jù)庫,修改用戶密碼,查看數(shù)據(jù)庫狀態(tài)等,mysqladmin常用的命令參數(shù)為:
            create databasename --:創(chuàng)建數(shù)據(jù)庫
            drop databasename ----:刪除數(shù)據(jù)庫及其所有相關(guān)的表
            extended-status ------:獲取MySQL服務(wù)器的詳細(xì)狀態(tài)
            kill id,id,... -------:殺掉MySQL的線程
            password new-password :修改用戶密碼
            ping -----------------:查看MySQL后臺進(jìn)程是否存在
            processlist ----------:顯示當(dāng)前的服務(wù)器的線程
            shutdown -------------:停止數(shù)據(jù)庫服務(wù)器
            status ---------------:獲取MySQL服務(wù)器狀態(tài)
            version --------------:查看MySQL服務(wù)器版本信息

            舉幾個簡單的例子,如下:
            1)修改MySQL用戶root的密碼為test,操作命令為:
            [root@ibmp630/usr/local/bin#]mysqladmin -u root -p password 'test'
            Enter password: <=== 輸入舊的用戶密碼
            2) 查看服務(wù)器的運(yùn)行狀態(tài)
            命令為:mysqladmin processlist status,例如:
            [root@ibmp630/usr/local/share/mysql#]mysqladmin -h ibmp630 proc stat
            +----+------+------+----+---------+------+-------+--------+
            | Id | User | Host | db | Command | Time | State | Info |
            +----+------+---------+----+---------+------+-------+-----+
            | 2 | root | ibmp630 | | Query | 0 | | show processlist |
            +----+------+---------+----+---------+------+-------+-----+
            Uptime: 39 Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1
            Open tables: 0 Queries per second avg: 0.051

            要介紹的第二個工具為msql,這是MySQL客戶端連結(jié)到服務(wù)器端的一個重要工具,通過它,我們可以得到一些更詳細(xì)的數(shù)據(jù)庫信息,完成對數(shù)據(jù)庫的操作,使用方法為:
            mysql –u user –p password
            正確連結(jié)到服務(wù)器系統(tǒng)將顯示如下提示符:
            mysql>

            簡單介紹在mysql工具中常用幾條命令,另外SQL語句的操作也是在mysql下完成的,對于SQL的操作,不再在此詳細(xì)描述,請參考相關(guān)的手冊。
            1)查看MySQL數(shù)據(jù)庫
            show databases; 例如:
            mysql> show databases;
            +----------+
            | Database |
            +----------+
            | mysql |
            | test |
            | testdb |
            +----------+
            3 rows in set (0.00 sec)

            2)查看當(dāng)前的數(shù)據(jù)庫
            select database(); 例如:
            mysql> select database();
            +------------+
            | database() |
            +------------+
            | testdb |
            +------------+
            1 row in set (0.06 sec)

            3) 打開并使用數(shù)據(jù)庫
            use database_name; 例如:
            mysql> use testdb;
            Reading table information for completion of table and column names
            You can turn off this feature to get a quicker startup with -A

            Database changed

            4) 查看表信息
            show tables;
            mysql> show tables;
            +------------------+
            | Tables_in_testdb |
            +------------------+
            | testtb |
            +------------------+
            1 row in set (0.00 sec)

            5) 查看表的結(jié)構(gòu)信息
            desc table_name
            mysql> desc db;
            +---------------+---------------+----+---+-------+-----+
            | Field --------| Type ---------|Null|Key|Default|Extra|
            +---------------+---------------+----+---+-------+-----+
            |Host ----------|char(60) binary| ---|PRI| ------| ----|
            |Db ------------|char(64) binary| ---|PRI| ------| ----|
            |User ----------|char(16) binary| ---|PRI| ------|---- |
            |Select_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Insert_priv----|enum('N','Y') -| ---| --| N ----|---- |
            |Update_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Delete_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Create_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Drop_priv -----|enum('N','Y') -| ---| --| N ----| ----|
            |Grant_priv ----|enum('N','Y') -| ---|-- | N ----| ----|
            |References_priv|enum('N','Y') -| ---|-- | N ----| ----|
            |Index_priv ----|enum('N','Y') -| ---| --| N ----|---- |
            |Alter_priv ----|enum('N','Y') -| ---| --| N ----| ----|
            +---------------+---------------+----+---+-------+-----+
            13 rows in set (0.00 sec)

            以上給出的知識MySQL的一些基本知識,這篇文章的目的是希望讀者看完后能基本操作
            MySQL數(shù)據(jù)庫,更完整的信息請參考MySQL的使用手冊。


            MySQL簡單使用
            MySQL最初廣泛地使用在Linux系統(tǒng),隨著MySQL的普及,在一些主流的UNIX系統(tǒng)中,如AIX,Solaris,也逐漸的多了起來,這篇文章將介紹如何在AIX平臺上使用MySQL數(shù)據(jù)庫。在以下的內(nèi)容中將按照數(shù)據(jù)庫初始化、數(shù)據(jù)庫管理、操作三個方面介紹。
            在介紹以下內(nèi)容之前,應(yīng)當(dāng)先清楚的知道MySQL分布,這里說的分布是指缺省情況下的安裝配置,其系統(tǒng)文件、數(shù)據(jù)文件、頭文件及提供的庫文件分布如下:
            系統(tǒng)文件: /usr/local/bin
            頭文件: /usr/local/include/mysql
            庫文件: /usr/local/lib/mysql
            數(shù)據(jù)庫文件:/var/mysql,按創(chuàng)建的數(shù)據(jù)庫名稱安樹狀結(jié)構(gòu)分布

            數(shù)據(jù)庫初始化
            通常情況下,MySQL初次安張結(jié)束后,如果直接運(yùn)行mysql連結(jié)MySQL數(shù)據(jù)庫服務(wù)器,會出
            現(xiàn)這樣的錯誤,Can't start server: Bind on TCP/IP port: Address already in use或者Can't start server : Bind on unix socket
            直觀的來看象是端口被占用的問題,實(shí)際上是MySQL未初始化引起的。對MySQL的初始化可通過運(yùn)行mysql_install_db來實(shí)現(xiàn),其輸出結(jié)果如下:
            [root@ibmp630/usr/local/bin#]./mysql_install_db
            Preparing db table
            Preparing host table
            Preparing user table
            Preparing func table
            Preparing tables_priv table
            Preparing columns_priv table
            Installing all prepared tables

            To start mysqld at boot time you have to copy support-files/mysql.server
            to the right place for your system

            PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
            This is done with:
            /usr/local/bin/mysqladmin -u root -p password 'new-password'
            /usr/local/bin/mysqladmin -u root -h ibmp630 -p password 'new-password'
            See the manual for more instructions.

            You can start the MySQL daemon with:
            cd /usr/local ; /usr/local/bin/safe_mysqld &
            You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
            cd sql-bench ; run-all-tests

            Please report any problems with the /usr/local/bin/mysqlbug script!

            The latest information about MySQL is available on the web at
            http://www.mysql.com
            Support MySQL by buying support/licenses at https://order.mysql.com

            從上面的輸出信息可以看出,mysql_install_db實(shí)際上是創(chuàng)建MySQL的權(quán)限信息,mysql_install_db并不覆蓋已經(jīng)存在的權(quán)限信息表,一般情況下,mysql_install_db只是在MySQL安裝完成后運(yùn)行一次既可。

            啟動停止數(shù)據(jù)庫
            數(shù)據(jù)庫的啟動和停止是最基本的操作,可以通過mysql.server和safe_mysqld啟動和停止MySQL。具體的操作方式為:
            1) 利用mysql.server,位置/usr/local/share/mysql
            啟動數(shù)據(jù)庫服務(wù)器:
            mysql.server start
            停止數(shù)據(jù)庫服務(wù)器:
            mysql.server stop
            實(shí)際上,mysql.server啟動服務(wù)器是通過safe_mysqld實(shí)現(xiàn)的。
            2) safe_mysqld
            safe_mysqld啟動服務(wù)器,不需要帶任何參數(shù),如下:
            safe_mysqld &
            停止數(shù)據(jù)庫,可以利用mysqladmin實(shí)現(xiàn),如下:
            mysqladmin shutdown

            數(shù)據(jù)庫管理
            對一些商業(yè)性的數(shù)據(jù)庫管理系統(tǒng),數(shù)據(jù)庫的管理是一個復(fù)雜的問題,如用戶管理、數(shù)據(jù)管理、表管理、系統(tǒng)優(yōu)化等等,MySQL數(shù)據(jù)庫系統(tǒng)也存在同樣的問題。這里只介紹mysqladmin和mysql兩個基本的工具,更詳細(xì)的操作請參考MySQL操作手冊。
            mysqladmin是最基本、常用的工具,如創(chuàng)建、刪除數(shù)據(jù)庫,修改用戶密碼,查看數(shù)據(jù)庫狀態(tài)等,mysqladmin常用的命令參數(shù)為:
            create databasename --:創(chuàng)建數(shù)據(jù)庫
            drop databasename ----:刪除數(shù)據(jù)庫及其所有相關(guān)的表
            extended-status ------:獲取MySQL服務(wù)器的詳細(xì)狀態(tài)
            kill id,id,... -------:殺掉MySQL的線程
            password new-password :修改用戶密碼
            ping -----------------:查看MySQL后臺進(jìn)程是否存在
            processlist ----------:顯示當(dāng)前的服務(wù)器的線程
            shutdown -------------:停止數(shù)據(jù)庫服務(wù)器
            status ---------------:獲取MySQL服務(wù)器狀態(tài)
            version --------------:查看MySQL服務(wù)器版本信息

            舉幾個簡單的例子,如下:
            1)修改MySQL用戶root的密碼為test,操作命令為:
            [root@ibmp630/usr/local/bin#]mysqladmin -u root -p password 'test'
            Enter password: <=== 輸入舊的用戶密碼
            2) 查看服務(wù)器的運(yùn)行狀態(tài)
            命令為:mysqladmin processlist status,例如:
            [root@ibmp630/usr/local/share/mysql#]mysqladmin -h ibmp630 proc stat
            +----+------+------+----+---------+------+-------+--------+
            | Id | User | Host | db | Command | Time | State | Info |
            +----+------+---------+----+---------+------+-------+-----+
            | 2 | root | ibmp630 | | Query | 0 | | show processlist |
            +----+------+---------+----+---------+------+-------+-----+
            Uptime: 39 Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1
            Open tables: 0 Queries per second avg: 0.051

            要介紹的第二個工具為msql,這是MySQL客戶端連結(jié)到服務(wù)器端的一個重要工具,通過它,我們可以得到一些更詳細(xì)的數(shù)據(jù)庫信息,完成對數(shù)據(jù)庫的操作,使用方法為:
            mysql –u user –p password
            正確連結(jié)到服務(wù)器系統(tǒng)將顯示如下提示符:
            mysql>

            簡單介紹在mysql工具中常用幾條命令,另外SQL語句的操作也是在mysql下完成的,對于SQL的操作,不再在此詳細(xì)描述,請參考相關(guān)的手冊。
            1)查看MySQL數(shù)據(jù)庫
            show databases; 例如:
            mysql> show databases;
            +----------+
            | Database |
            +----------+
            | mysql |
            | test |
            | testdb |
            +----------+
            3 rows in set (0.00 sec)

            2)查看當(dāng)前的數(shù)據(jù)庫
            select database(); 例如:
            mysql> select database();
            +------------+
            | database() |
            +------------+
            | testdb |
            +------------+
            1 row in set (0.06 sec)

            3) 打開并使用數(shù)據(jù)庫
            use database_name; 例如:
            mysql> use testdb;
            Reading table information for completion of table and column names
            You can turn off this feature to get a quicker startup with -A

            Database changed

            4) 查看表信息
            show tables;
            mysql> show tables;
            +------------------+
            | Tables_in_testdb |
            +------------------+
            | testtb |
            +------------------+
            1 row in set (0.00 sec)

            5) 查看表的結(jié)構(gòu)信息
            desc table_name
            mysql> desc db;
            +---------------+---------------+----+---+-------+-----+
            | Field --------| Type ---------|Null|Key|Default|Extra|
            +---------------+---------------+----+---+-------+-----+
            |Host ----------|char(60) binary| ---|PRI| ------| ----|
            |Db ------------|char(64) binary| ---|PRI| ------| ----|
            |User ----------|char(16) binary| ---|PRI| ------|---- |
            |Select_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Insert_priv----|enum('N','Y') -| ---| --| N ----|---- |
            |Update_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Delete_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Create_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Drop_priv -----|enum('N','Y') -| ---| --| N ----| ----|
            |Grant_priv ----|enum('N','Y') -| ---|-- | N ----| ----|
            |References_priv|enum('N','Y') -| ---|-- | N ----| ----|
            |Index_priv ----|enum('N','Y') -| ---| --| N ----|---- |
            |Alter_priv ----|enum('N','Y') -| ---| --| N ----| ----|
            +---------------+---------------+----+---+-------+-----+
            13 rows in set (0.00 sec)

            以上給出的知識MySQL的一些基本知識,這篇文章的目的是希望讀者看完后能基本操作
            MySQL數(shù)據(jù)庫,更完整的信息請參考MySQL的使用手冊。

            MySQL簡單使用
            MySQL最初廣泛地使用在Linux系統(tǒng),隨著MySQL的普及,在一些主流的UNIX系統(tǒng)中,如AIX,Solaris,也逐漸的多了起來,這篇文章將介紹如何在AIX平臺上使用MySQL數(shù)據(jù)庫。在以下的內(nèi)容中將按照數(shù)據(jù)庫初始化、數(shù)據(jù)庫管理、操作三個方面介紹。
            在介紹以下內(nèi)容之前,應(yīng)當(dāng)先清楚的知道MySQL分布,這里說的分布是指缺省情況下的安裝配置,其系統(tǒng)文件、數(shù)據(jù)文件、頭文件及提供的庫文件分布如下:
            系統(tǒng)文件: /usr/local/bin
            頭文件: /usr/local/include/mysql
            庫文件: /usr/local/lib/mysql
            數(shù)據(jù)庫文件:/var/mysql,按創(chuàng)建的數(shù)據(jù)庫名稱安樹狀結(jié)構(gòu)分布

            數(shù)據(jù)庫初始化
            通常情況下,MySQL初次安張結(jié)束后,如果直接運(yùn)行mysql連結(jié)MySQL數(shù)據(jù)庫服務(wù)器,會出
            現(xiàn)這樣的錯誤,Can't start server: Bind on TCP/IP port: Address already in use或者Can't start server : Bind on unix socket
            直觀的來看象是端口被占用的問題,實(shí)際上是MySQL未初始化引起的。對MySQL的初始化可通過運(yùn)行mysql_install_db來實(shí)現(xiàn),其輸出結(jié)果如下:
            [root@ibmp630/usr/local/bin#]./mysql_install_db
            Preparing db table
            Preparing host table
            Preparing user table
            Preparing func table
            Preparing tables_priv table
            Preparing columns_priv table
            Installing all prepared tables

            To start mysqld at boot time you have to copy support-files/mysql.server
            to the right place for your system

            PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
            This is done with:
            /usr/local/bin/mysqladmin -u root -p password 'new-password'
            /usr/local/bin/mysqladmin -u root -h ibmp630 -p password 'new-password'
            See the manual for more instructions.

            You can start the MySQL daemon with:
            cd /usr/local ; /usr/local/bin/safe_mysqld &
            You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
            cd sql-bench ; run-all-tests

            Please report any problems with the /usr/local/bin/mysqlbug script!

            The latest information about MySQL is available on the web at
            http://www.mysql.com
            Support MySQL by buying support/licenses at https://order.mysql.com

            從上面的輸出信息可以看出,mysql_install_db實(shí)際上是創(chuàng)建MySQL的權(quán)限信息,mysql_install_db并不覆蓋已經(jīng)存在的權(quán)限信息表,一般情況下,mysql_install_db只是在MySQL安裝完成后運(yùn)行一次既可。

            啟動停止數(shù)據(jù)庫
            數(shù)據(jù)庫的啟動和停止是最基本的操作,可以通過mysql.server和safe_mysqld啟動和停止MySQL。具體的操作方式為:
            1) 利用mysql.server,位置/usr/local/share/mysql
            啟動數(shù)據(jù)庫服務(wù)器:
            mysql.server start
            停止數(shù)據(jù)庫服務(wù)器:
            mysql.server stop
            實(shí)際上,mysql.server啟動服務(wù)器是通過safe_mysqld實(shí)現(xiàn)的。
            2) safe_mysqld
            safe_mysqld啟動服務(wù)器,不需要帶任何參數(shù),如下:
            safe_mysqld &
            停止數(shù)據(jù)庫,可以利用mysqladmin實(shí)現(xiàn),如下:
            mysqladmin shutdown

            數(shù)據(jù)庫管理
            對一些商業(yè)性的數(shù)據(jù)庫管理系統(tǒng),數(shù)據(jù)庫的管理是一個復(fù)雜的問題,如用戶管理、數(shù)據(jù)管理、表管理、系統(tǒng)優(yōu)化等等,MySQL數(shù)據(jù)庫系統(tǒng)也存在同樣的問題。這里只介紹mysqladmin和mysql兩個基本的工具,更詳細(xì)的操作請參考MySQL操作手冊。
            mysqladmin是最基本、常用的工具,如創(chuàng)建、刪除數(shù)據(jù)庫,修改用戶密碼,查看數(shù)據(jù)庫狀態(tài)等,mysqladmin常用的命令參數(shù)為:
            create databasename --:創(chuàng)建數(shù)據(jù)庫
            drop databasename ----:刪除數(shù)據(jù)庫及其所有相關(guān)的表
            extended-status ------:獲取MySQL服務(wù)器的詳細(xì)狀態(tài)
            kill id,id,... -------:殺掉MySQL的線程
            password new-password :修改用戶密碼
            ping -----------------:查看MySQL后臺進(jìn)程是否存在
            processlist ----------:顯示當(dāng)前的服務(wù)器的線程
            shutdown -------------:停止數(shù)據(jù)庫服務(wù)器
            status ---------------:獲取MySQL服務(wù)器狀態(tài)
            version --------------:查看MySQL服務(wù)器版本信息

            舉幾個簡單的例子,如下:
            1)修改MySQL用戶root的密碼為test,操作命令為:
            [root@ibmp630/usr/local/bin#]mysqladmin -u root -p password 'test'
            Enter password: <=== 輸入舊的用戶密碼
            2) 查看服務(wù)器的運(yùn)行狀態(tài)
            命令為:mysqladmin processlist status,例如:
            [root@ibmp630/usr/local/share/mysql#]mysqladmin -h ibmp630 proc stat
            +----+------+------+----+---------+------+-------+--------+
            | Id | User | Host | db | Command | Time | State | Info |
            +----+------+---------+----+---------+------+-------+-----+
            | 2 | root | ibmp630 | | Query | 0 | | show processlist |
            +----+------+---------+----+---------+------+-------+-----+
            Uptime: 39 Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1
            Open tables: 0 Queries per second avg: 0.051

            要介紹的第二個工具為msql,這是MySQL客戶端連結(jié)到服務(wù)器端的一個重要工具,通過它,我們可以得到一些更詳細(xì)的數(shù)據(jù)庫信息,完成對數(shù)據(jù)庫的操作,使用方法為:
            mysql –u user –p password
            正確連結(jié)到服務(wù)器系統(tǒng)將顯示如下提示符:
            mysql>

            簡單介紹在mysql工具中常用幾條命令,另外SQL語句的操作也是在mysql下完成的,對于SQL的操作,不再在此詳細(xì)描述,請參考相關(guān)的手冊。
            1)查看MySQL數(shù)據(jù)庫
            show databases; 例如:
            mysql> show databases;
            +----------+
            | Database |
            +----------+
            | mysql |
            | test |
            | testdb |
            +----------+
            3 rows in set (0.00 sec)

            2)查看當(dāng)前的數(shù)據(jù)庫
            select database(); 例如:
            mysql> select database();
            +------------+
            | database() |
            +------------+
            | testdb |
            +------------+
            1 row in set (0.06 sec)

            3) 打開并使用數(shù)據(jù)庫
            use database_name; 例如:
            mysql> use testdb;
            Reading table information for completion of table and column names
            You can turn off this feature to get a quicker startup with -A

            Database changed

            4) 查看表信息
            show tables;
            mysql> show tables;
            +------------------+
            | Tables_in_testdb |
            +------------------+
            | testtb |
            +------------------+
            1 row in set (0.00 sec)

            5) 查看表的結(jié)構(gòu)信息
            desc table_name
            mysql> desc db;
            +---------------+---------------+----+---+-------+-----+
            | Field --------| Type ---------|Null|Key|Default|Extra|
            +---------------+---------------+----+---+-------+-----+
            |Host ----------|char(60) binary| ---|PRI| ------| ----|
            |Db ------------|char(64) binary| ---|PRI| ------| ----|
            |User ----------|char(16) binary| ---|PRI| ------|---- |
            |Select_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Insert_priv----|enum('N','Y') -| ---| --| N ----|---- |
            |Update_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Delete_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Create_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Drop_priv -----|enum('N','Y') -| ---| --| N ----| ----|
            |Grant_priv ----|enum('N','Y') -| ---|-- | N ----| ----|
            |References_priv|enum('N','Y') -| ---|-- | N ----| ----|
            |Index_priv ----|enum('N','Y') -| ---| --| N ----|---- |
            |Alter_priv ----|enum('N','Y') -| ---| --| N ----| ----|
            +---------------+---------------+----+---+-------+-----+
            13 rows in set (0.00 sec)

            以上給出的知識MySQL的一些基本知識,這篇文章的目的是希望讀者看完后能基本操作
            MySQL數(shù)據(jù)庫,更完整的信息請參考MySQL的使用手冊。

            MySQL最初廣泛地使用在Linux系統(tǒng),隨著MySQL的普及,在一些主流的UNIX系統(tǒng)中,如AIX,Solaris,也逐漸的多了起來,這篇文章將介紹如何在AIX平臺上使用MySQL數(shù)據(jù)庫。在以下的內(nèi)容中將按照數(shù)據(jù)庫初始化、數(shù)據(jù)庫管理、操作三個方面介紹。
            在介紹以下內(nèi)容之前,應(yīng)當(dāng)先清楚的知道MySQL分布,這里說的分布是指缺省情況下的安裝配置,其系統(tǒng)文件、數(shù)據(jù)文件、頭文件及提供的庫文件分布如下:
            系統(tǒng)文件: /usr/local/bin
            頭文件: /usr/local/include/mysql
            庫文件: /usr/local/lib/mysql
            數(shù)據(jù)庫文件:/var/mysql,按創(chuàng)建的數(shù)據(jù)庫名稱安樹狀結(jié)構(gòu)分布

            數(shù)據(jù)庫初始化
            通常情況下,MySQL初次安張結(jié)束后,如果直接運(yùn)行mysql連結(jié)MySQL數(shù)據(jù)庫服務(wù)器,會出
            現(xiàn)這樣的錯誤,Can't start server: Bind on TCP/IP port: Address already in use或者Can't start server : Bind on unix socket
            直觀的來看象是端口被占用的問題,實(shí)際上是MySQL未初始化引起的。對MySQL的初始化可通過運(yùn)行mysql_install_db來實(shí)現(xiàn),其輸出結(jié)果如下:
            [root@ibmp630/usr/local/bin#]./mysql_install_db
            Preparing db table
            Preparing host table
            Preparing user table
            Preparing func table
            Preparing tables_priv table
            Preparing columns_priv table
            Installing all prepared tables

            To start mysqld at boot time you have to copy support-files/mysql.server
            to the right place for your system

            PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
            This is done with:
            /usr/local/bin/mysqladmin -u root -p password 'new-password'
            /usr/local/bin/mysqladmin -u root -h ibmp630 -p password 'new-password'
            See the manual for more instructions.

            You can start the MySQL daemon with:
            cd /usr/local ; /usr/local/bin/safe_mysqld &
            You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
            cd sql-bench ; run-all-tests

            Please report any problems with the /usr/local/bin/mysqlbug script!

            The latest information about MySQL is available on the web at
            http://www.mysql.com
            Support MySQL by buying support/licenses at https://order.mysql.com

            從上面的輸出信息可以看出,mysql_install_db實(shí)際上是創(chuàng)建MySQL的權(quán)限信息,mysql_install_db并不覆蓋已經(jīng)存在的權(quán)限信息表,一般情況下,mysql_install_db只是在MySQL安裝完成后運(yùn)行一次既可。

            啟動停止數(shù)據(jù)庫
            數(shù)據(jù)庫的啟動和停止是最基本的操作,可以通過mysql.server和safe_mysqld啟動和停止MySQL。具體的操作方式為:
            1) 利用mysql.server,位置/usr/local/share/mysql
            啟動數(shù)據(jù)庫服務(wù)器:
            mysql.server start
            停止數(shù)據(jù)庫服務(wù)器:
            mysql.server stop
            實(shí)際上,mysql.server啟動服務(wù)器是通過safe_mysqld實(shí)現(xiàn)的。
            2) safe_mysqld
            safe_mysqld啟動服務(wù)器,不需要帶任何參數(shù),如下:
            safe_mysqld &
            停止數(shù)據(jù)庫,可以利用mysqladmin實(shí)現(xiàn),如下:
            mysqladmin shutdown

            數(shù)據(jù)庫管理
            對一些商業(yè)性的數(shù)據(jù)庫管理系統(tǒng),數(shù)據(jù)庫的管理是一個復(fù)雜的問題,如用戶管理、數(shù)據(jù)管理、表管理、系統(tǒng)優(yōu)化等等,MySQL數(shù)據(jù)庫系統(tǒng)也存在同樣的問題。這里只介紹mysqladmin和mysql兩個基本的工具,更詳細(xì)的操作請參考MySQL操作手冊。
            mysqladmin是最基本、常用的工具,如創(chuàng)建、刪除數(shù)據(jù)庫,修改用戶密碼,查看數(shù)據(jù)庫狀態(tài)等,mysqladmin常用的命令參數(shù)為:
            create databasename --:創(chuàng)建數(shù)據(jù)庫
            drop databasename ----:刪除數(shù)據(jù)庫及其所有相關(guān)的表
            extended-status ------:獲取MySQL服務(wù)器的詳細(xì)狀態(tài)
            kill id,id,... -------:殺掉MySQL的線程
            password new-password :修改用戶密碼
            ping -----------------:查看MySQL后臺進(jìn)程是否存在
            processlist ----------:顯示當(dāng)前的服務(wù)器的線程
            shutdown -------------:停止數(shù)據(jù)庫服務(wù)器
            status ---------------:獲取MySQL服務(wù)器狀態(tài)
            version --------------:查看MySQL服務(wù)器版本信息

            舉幾個簡單的例子,如下:
            1)修改MySQL用戶root的密碼為test,操作命令為:
            [root@ibmp630/usr/local/bin#]mysqladmin -u root -p password 'test'
            Enter password: <=== 輸入舊的用戶密碼
            2) 查看服務(wù)器的運(yùn)行狀態(tài)
            命令為:mysqladmin processlist status,例如:
            [root@ibmp630/usr/local/share/mysql#]mysqladmin -h ibmp630 proc stat
            +----+------+------+----+---------+------+-------+--------+
            | Id | User | Host | db | Command | Time | State | Info |
            +----+------+---------+----+---------+------+-------+-----+
            | 2 | root | ibmp630 | | Query | 0 | | show processlist |
            +----+------+---------+----+---------+------+-------+-----+
            Uptime: 39 Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1
            Open tables: 0 Queries per second avg: 0.051

            要介紹的第二個工具為msql,這是MySQL客戶端連結(jié)到服務(wù)器端的一個重要工具,通過它,我們可以得到一些更詳細(xì)的數(shù)據(jù)庫信息,完成對數(shù)據(jù)庫的操作,使用方法為:
            mysql –u user –p password
            正確連結(jié)到服務(wù)器系統(tǒng)將顯示如下提示符:
            mysql>

            簡單介紹在mysql工具中常用幾條命令,另外SQL語句的操作也是在mysql下完成的,對于SQL的操作,不再在此詳細(xì)描述,請參考相關(guān)的手冊。
            1)查看MySQL數(shù)據(jù)庫
            show databases; 例如:
            mysql> show databases;
            +----------+
            | Database |
            +----------+
            | mysql |
            | test |
            | testdb |
            +----------+
            3 rows in set (0.00 sec)

            2)查看當(dāng)前的數(shù)據(jù)庫
            select database(); 例如:
            mysql> select database();
            +------------+
            | database() |
            +------------+
            | testdb |
            +------------+
            1 row in set (0.06 sec)

            3) 打開并使用數(shù)據(jù)庫
            use database_name; 例如:
            mysql> use testdb;
            Reading table information for completion of table and column names
            You can turn off this feature to get a quicker startup with -A

            Database changed

            4) 查看表信息
            show tables;
            mysql> show tables;
            +------------------+
            | Tables_in_testdb |
            +------------------+
            | testtb |
            +------------------+
            1 row in set (0.00 sec)

            5) 查看表的結(jié)構(gòu)信息
            desc table_name
            mysql> desc db;
            +---------------+---------------+----+---+-------+-----+
            | Field --------| Type ---------|Null|Key|Default|Extra|
            +---------------+---------------+----+---+-------+-----+
            |Host ----------|char(60) binary| ---|PRI| ------| ----|
            |Db ------------|char(64) binary| ---|PRI| ------| ----|
            |User ----------|char(16) binary| ---|PRI| ------|---- |
            |Select_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Insert_priv----|enum('N','Y') -| ---| --| N ----|---- |
            |Update_priv ---|enum('N','Y') -| ---| --| N ----| ----|
            |Delete_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Create_priv ---|enum('N','Y') -| ---| --| N ----|---- |
            |Drop_priv -----|enum('N','Y') -| ---| --| N ----| ----|
            |Grant_priv ----|enum('N','Y') -| ---|-- | N ----| ----|
            |References_priv|enum('N','Y') -| ---|-- | N ----| ----|
            |Index_priv ----|enum('N','Y') -| ---| --| N ----|---- |
            |Alter_priv ----|enum('N','Y') -| ---| --| N ----| ----|
            +---------------+---------------+----+---+-------+-----+
            13 rows in set (0.00 sec)

            以上給出的知識MySQL的一些基本知識,這篇文章的目的是希望讀者看完后能基本操作
            MySQL數(shù)據(jù)庫,更完整的信息請參考MySQL的使用手冊。

            posted on 2010-06-26 13:05 楊粼波 閱讀(1177) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            亚洲国产成人久久精品动漫| 久久精品国产亚洲Aⅴ香蕉| 人人狠狠综合久久亚洲婷婷| 亚洲欧美日韩久久精品| 嫩草伊人久久精品少妇AV| 精品欧美一区二区三区久久久| 色偷偷偷久久伊人大杳蕉| 韩国无遮挡三级久久| 久久久久久精品成人免费图片| 无码任你躁久久久久久| AAA级久久久精品无码片| 久久受www免费人成_看片中文| 性做久久久久久免费观看| 精品熟女少妇a∨免费久久| 亚洲精品NV久久久久久久久久| 久久久久久极精品久久久| 99久久人妻无码精品系列蜜桃| 97久久国产亚洲精品超碰热| 久久久久久久波多野结衣高潮| 国产A三级久久精品| 久久国产乱子伦精品免费午夜| 久久久久99精品成人片| 国产欧美久久久精品| 久久免费的精品国产V∧| 亚州日韩精品专区久久久| 久久成人国产精品一区二区| 久久香蕉一级毛片| 99久久精品日本一区二区免费| 久久久久久a亚洲欧洲aⅴ | 性做久久久久久久| 久久久久久国产精品美女 | 久久婷婷色香五月综合激情| 99久久国产免费福利| 久久成人精品视频| 国产精品一区二区久久国产| 久久亚洲私人国产精品vA| 久久久久亚洲AV无码永不| 99国产欧美精品久久久蜜芽| 国产精品久久自在自线观看| 欧美久久精品一级c片片| 青青草国产成人久久91网|