MySQL 5.6.21下載安裝之安裝篇(二)

zhangsharp20發表於2016-03-17

 

mysql安裝

 

clip_image002

1.1 Linux之下MySQL安裝的三種方案的比較

具體內容參考這篇bloghttp://blog.itpub.net/8183550/viewspace-680749/

 

一.1  windows 下安裝(mysql-5.6.21-win32)

一.1.1  mysql server 安裝

 

1登入   http://dev.mysql.com/downloads/

wps10F7.tmp[4]wps1108.tmp[4] 

2進入如下頁面:(該圖為頁面最底部)

wps1109.tmp[4]wps110A.tmp[4] 

 

 

3下載完成解壓該檔案mysql-5.6.21-win32.zip

wps6CA5.tmpwps6CB5.tmp 

4開啟檔案mysql-5.6.21-win32

wps6CB6.tmp

5用記事本開啟my-default.ini

wps6CB7.tmpwps6CC8.tmp 

 

修改

basedir=C:\Program Files\MySQL\MySQL Server 5.6(mysql所在目錄)

datadir=C:\Program Files\MySQL\MySQL Server 5.6\data (mysql所在目錄\data)

 

wps6CC9.tmp wps6CD9.tmp

完成上述步驟之後,很多使用者開始使用MySQL,但會出現圖示的錯誤。這是因為沒有配置環境變數所致。

配置環境變數很簡單:

我的電腦->屬性->高階->環境變數

選擇PATH,在其後面新增: 你的mysql bin資料夾的路徑 (如:C:\Program Files\MySQL\MySQL Server 5.6\bin )

PATH=.......;C:\Program Files\MySQL\MySQL Server 5.6\bin (注意是追加,不是覆蓋)

wps6CDA.tmp 

以管理員身份執行cmd(一定要用管理員身份執行,不然許可權不夠),

輸入:cd C:\Program Files\MySQL\MySQL Server 5.6\bin 進入mysql的bin資料夾(不管有沒有配置過環境變數,也要進入bin資料夾,否則之後啟動服務仍然會報錯誤2)

輸入mysqld -install  (如果不用管理員身份執行,將會因為許可權不夠而出現錯誤:Install/Remove of the Service Denied!)

安裝成功

wps6CDB.tmp 

 

安裝成功後就要啟動服務了,繼續在cmd中輸入:net start mysql(如圖),服務啟動成功!

wps6CDC.tmp 

mysqld -install  執行成功後就在系統的服務裡新增了如下服務:

wps6CDD.tmp 

 

在cmd輸入命令mysqladmin -uroot -p password (新密碼)

Enter password:(初始密碼沒有,所以直接回車)

密碼設定成功。

wps6CDE.tmp 

 

 

一.1.1  mysql-workbench-community-6.2.3-win32-noinstall

登入http://dev.mysql.com/downloads/ 

wpsDC51.tmpwpsDC62.tmp

 

 

進入如下頁面:

 wps6CF1.tmp

 wps6CF2.tmp 解壓mysql-workbench-community-6.2.3-win32-noinstall.zip

wps6D03.tmp

開啟檔案D:\Program files\MySQL\MySQL Workbench 6.2.4 CE (winx64)

wps6D05.tmp 

wps6D06.tmp 

wps6D16.tmp 

 

填寫相應的條件就可以連線資料庫了

 

 

安裝成功2個條件:

 

:安裝MySQL workbench需安裝

1.microsoft visual c++ 2013

2.wps6D17.tmp

wps6D18.tmp 

 

MySQL Workbench Prerequisites:

To be able to install and run MySQL Workbench your System needs to have libraries listed below installed. The listed items are provided as links to the corresponding download pages where you can fetch the necessary files.

· 

· 

 

一.1  linux下安裝--rpm安裝

下載安裝包後將安裝包利用ftp軟體上傳到server端,如圖:

wps6D19.tmp 

 

MD5值校驗:

[root@rhel6_lhr Downloads]# md5sum MySQL\ Database\ 5.6.21\ RPM\ for\ Oracle\ Linux\ \ RHEL\ 6\ x86\ \(64bit\).zip

c4dc6be57e494825fac08a219399190d  MySQL Database 5.6.21 RPM for Oracle Linux  RHEL 6 x86 (64bit).zip

[root@rhel6_lhr Downloads]#

 

 

解壓縮之後:

 

unzip MySQL Database 5.6.21 RPM for Oracle Linux  RHEL 6 x86 (64bit).zip

 

wps6D1A.tmp 

[root@rhel6_lhr Downloads]# ll

total 227184

-rw-r--r--. 1 root root 232632160 Nov 26 20:32 MySQL Database 5.6.21 RPM for Oracle Linux  RHEL 6 x86 (64bit).zip

[root@rhel6_lhr Downloads]# unzip MySQL\ Database\ 5.6.21\ RPM\ for\ Oracle\ Linux\ \ RHEL\ 6\ x86\ \(64bit\).zip

Archive:  MySQL Database 5.6.21 RPM for Oracle Linux  RHEL 6 x86 (64bit).zip

extracting: MySQL-client-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: MySQL-server-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: MySQL-devel-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: MySQL-shared-compat-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: MySQL-embedded-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: MySQL-shared-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: MySQL-test-advanced-5.6.21-1.el6.x86_64.rpm 

extracting: README.txt             

[root@rhel6_lhr Downloads]# ll

total 454376

-rwxr-xr-x. 1 root root  18706988 Sep 12 10:25 MySQL-client-advanced-5.6.21-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 232632160 Nov 26 20:32 MySQL Database 5.6.21 RPM for Oracle Linux  RHEL 6 x86 (64bit).zip

-rwxr-xr-x. 1 root root   3292908 Sep 12 10:25 MySQL-devel-advanced-5.6.21-1.el6.x86_64.rpm

-rwxr-xr-x. 1 root root  88742236 Sep 12 10:26 MySQL-embedded-advanced-5.6.21-1.el6.x86_64.rpm

-rwxr-xr-x. 1 root root  65023820 Sep 12 10:27 MySQL-server-advanced-5.6.21-1.el6.x86_64.rpm

-rwxr-xr-x. 1 root root   2021044 Sep 12 10:27 MySQL-shared-advanced-5.6.21-1.el6.x86_64.rpm

-rwxr-xr-x. 1 root root   3945172 Sep 23 16:01 MySQL-shared-compat-advanced-5.6.21-1.el6.x86_64.rpm

-rwxr-xr-x. 1 root root  50883224 Sep 12 10:28 MySQL-test-advanced-5.6.21-1.el6.x86_64.rpm

-rwxr-xr-x. 1 root root     15476 Sep 23 07:10 README.txt

[root@rhel6_lhr Downloads]#

 

基本情況下安裝clientserver就可以了。

[root@rhel6_lhr Downloads]# rpm -ivh MySQL-client-advanced-5.6.21-1.el6.x86_64.rpm

Preparing...                ########################################### [100%]

   1:MySQL-client-advanced  ########################################### [100%]

[root@rhel6_lhr Downloads]#

 

採用yum安裝:

[root@rhel6_lhr Downloads]# yum install MySQL-server-advanced-5.6.21-1.el6.x86_64.rpm

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Examining MySQL-server-advanced-5.6.21-1.el6.x86_64.rpm: MySQL-server-advanced-5.6.21-1.el6.x86_64

Marking MySQL-server-advanced-5.6.21-1.el6.x86_64.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package MySQL-server-advanced.x86_64 0:5.6.21-1.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===============================================================================================================================================================================================================================================================================

Package                                                           Arch                                               Version                                                     Repository                                                                              Size

===============================================================================================================================================================================================================================================================================

Installing:

MySQL-server-advanced                                             x86_64                                             5.6.21-1.el6                                                /MySQL-server-advanced-5.6.21-1.el6.x86_64                                             255 M

 

Transaction Summary

===============================================================================================================================================================================================================================================================================

Install       1 Package(s)

 

Total size: 255 M

Installed size: 255 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : MySQL-server-advanced-5.6.21-1.el6.x86_64                                                                                                                                                                                                                   1/1

warning: user mysql does not exist - using root

warning: group mysql does not exist - using root

2014-11-27 09:56:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2014-11-27 09:56:47 356 [Note] InnoDB: Using atomics to ref count buffer pool pages

2014-11-27 09:56:47 356 [Note] InnoDB: The InnoDB memory heap is disabled

2014-11-27 09:56:47 356 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2014-11-27 09:56:47 356 [Note] InnoDB: Memory barrier is not used

2014-11-27 09:56:47 356 [Note] InnoDB: Compressed tables use zlib 1.2.3

2014-11-27 09:56:47 356 [Note] InnoDB: Using Linux native AIO

2014-11-27 09:56:47 356 [Note] InnoDB: Using CPU crc32 instructions

2014-11-27 09:56:47 356 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2014-11-27 09:56:47 356 [Note] InnoDB: Completed initialization of buffer pool

2014-11-27 09:56:47 356 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2014-11-27 09:56:47 356 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2014-11-27 09:56:47 356 [Note] InnoDB: Database physically writes the file full: wait...

2014-11-27 09:56:48 356 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2014-11-27 09:56:49 356 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2014-11-27 09:56:50 356 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2014-11-27 09:56:50 356 [Warning] InnoDB: New log files created, LSN=45781

2014-11-27 09:56:50 356 [Note] InnoDB: Doublewrite buffer not found: creating new

2014-11-27 09:56:50 356 [Note] InnoDB: Doublewrite buffer created

2014-11-27 09:56:50 356 [Note] InnoDB: 128 rollback segment(s) are active.

2014-11-27 09:56:50 356 [Warning] InnoDB: Creating foreign key constraint system tables.

2014-11-27 09:56:50 356 [Note] InnoDB: Foreign key constraint system tables created

2014-11-27 09:56:50 356 [Note] InnoDB: Creating tablespace and datafile system tables.

2014-11-27 09:56:50 356 [Note] InnoDB: Tablespace and datafile system tables created.

2014-11-27 09:56:50 356 [Note] InnoDB: Waiting for purge to start

2014-11-27 09:56:50 356 [Note] InnoDB: 5.6.21 started; log sequence number 0

2014-11-27 09:56:50 356 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.

2014-11-27 09:56:50 356 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.

2014-11-27 09:56:51 356 [Note] Binlog end

2014-11-27 09:56:51 356 [Note] InnoDB: FTS optimize thread exiting.

2014-11-27 09:56:51 356 [Note] InnoDB: Starting shutdown...

2014-11-27 09:56:53 356 [Note] InnoDB: Shutdown completed; log sequence number 1625977

A random root password has been set. You will find it in '/root/.mysql_secret'.

 

 

2014-11-27 09:56:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2014-11-27 09:56:53 382 [Note] InnoDB: Using atomics to ref count buffer pool pages

2014-11-27 09:56:53 382 [Note] InnoDB: The InnoDB memory heap is disabled

2014-11-27 09:56:53 382 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2014-11-27 09:56:53 382 [Note] InnoDB: Memory barrier is not used

2014-11-27 09:56:53 382 [Note] InnoDB: Compressed tables use zlib 1.2.3

2014-11-27 09:56:53 382 [Note] InnoDB: Using Linux native AIO

2014-11-27 09:56:53 382 [Note] InnoDB: Using CPU crc32 instructions

2014-11-27 09:56:53 382 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2014-11-27 09:56:53 382 [Note] InnoDB: Completed initialization of buffer pool

2014-11-27 09:56:53 382 [Note] InnoDB: Highest supported file format is Barracuda.

2014-11-27 09:56:53 382 [Note] InnoDB: 128 rollback segment(s) are active.

2014-11-27 09:56:53 382 [Note] InnoDB: Waiting for purge to start

2014-11-27 09:56:53 382 [Note] InnoDB: 5.6.21 started; log sequence number 1625977

2014-11-27 09:56:53 382 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.

2014-11-27 09:56:53 382 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.

2014-11-27 09:56:53 382 [Note] Binlog end

2014-11-27 09:56:53 382 [Note] InnoDB: FTS optimize thread exiting.

2014-11-27 09:56:53 382 [Note] InnoDB: Starting shutdown...

2014-11-27 09:56:55 382 [Note] InnoDB: Shutdown completed; log sequence number 1625987

 

 

 

 

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

 

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

 

Also, the account for the anonymous user has been removed.

 

In addition, you can run:

 

  /usr/bin/mysql_secure_installation

 

which will also give you the option of removing the test database.

This is strongly recommended for production servers.

 

See the manual for more instructions.

 

Please report any problems at

 

The latest information about MySQL is available on the web at

 

 

 

Support MySQL by buying support/licenses at

 

New default config file was created as /usr/my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

 

  Verifying  : MySQL-server-advanced-5.6.21-1.el6.x86_64                                                                                                                                                                                                                   1/1

 

Installed:

  MySQL-server-advanced.x86_64 0:5.6.21-1.el6                                                                                                                                                                                                                                 

 

Complete!

[root@rhel6_lhr Downloads]#

以上紅色字型大概是說一個隨機密碼已經設定了,'/root/.mysql_secret'可以看到,/usr/my.cnf 是預設的配置檔案,還有其他的一些等等。。。

wps6D2B.tmp 

 

檢視隨機密碼:

[root@rhel6_lhr ~]# more /root/.mysql_secret

# The random password set for the root user at Thu Nov 27 09:56:51 2014 (local time): nIchCMdDyQU43HnK

 

[root@rhel6_lhr ~]#

wps6D2C.tmp 

 

一.1.1  啟動服務

/etc/init.d/mysql start  或  service mysql start

 

[root@rhel6_lhr ~]# service mysql start

Starting MySQL... SUCCESS!

[root@rhel6_lhr ~]#

 

修改密碼,執行/root/mysql_secure_installation

 

[root@rhel6_lhr ~]# pwd

/root

[root@rhel6_lhr ~]# mysql_secure_installation

 

 

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log into MySQL to secure it, we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

 

You already have a root password set, so you can safely answer 'n'.

 

Change the root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

 

 

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y

... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n

... skipping.

 

By default, MySQL comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y^Hn

... skipping.

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

... Success!

 

 

 

 

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

 

Thanks for using MySQL!

 

 

Cleaning up...

[root@rhel6_lhr ~]#

 

一.1.2  連線mysql

wps6D2D.tmp 

wps6D2E.tmp 

wps6D3F.tmp 

 

 

一.1.3  登入

幫助: mysqladmin --help | less

 

 

1. mysql -h192.168.59.130 -uroot -P3300 -p

2. mysql -p

3. mysql -uroot -p

4. mysql -u root -p

5. mysql -S ./mysql.sock --protocol=socket -p

6. mysql -h localhost --protocol=tcp -p

7. mysql -uroot -h localhost -P 3306 -p

8. mysql -uroot -h 192.168.59.130 -P 3306 -p

9. mysql -uroot -h192.168.59.130 -p 

 

[root@rhel6_lhr ~]# mysql -plhr

Warning: Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 11

Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

 

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

Bye

[root@rhel6_lhr ~]# mysql -p

Enter password:

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

Your MySQL connection id is 12

Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

 

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

一.1.4  一些簡單的sql語句

 

一.1.4.1  建資料庫

1. create database  dbname;

2. drop database dbname;

3. show databases;

 

[root@rhel6_lhr ~]# mysql -p

Enter password:

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

Your MySQL connection id is 15

Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

 

Copyright (c) 2000, 2014, 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> show databases;

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

| Database           |

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

| information_schema |

| lhr_test           |

| mysql              |

| performance_schema |

| test               |

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

5 rows in set (0.00 sec)

 

mysql> drop database lhr_test;

Query OK, 0 rows affected (0.26 sec)

 

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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

4 rows in set (0.00 sec)

 

mysql> create database lhr_test;

Query OK, 1 row affected (0.00 sec)

 

mysql> show databases;

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

| Database           |

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

| information_schema |

| lhr_test           |

| mysql              |

| performance_schema |

| test               |

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

5 rows in set (0.00 sec)

 

mysql>

 

 

 

一.1.4.2  建立和刪除表

1. create table t1(id int(10),name varchar(20));

2. drop table t1;

3. show tables;

4. use dbname;

 

[root@rhel6_lhr ~]# mysql -p

Enter password:

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

Your MySQL connection id is 17

Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

 

Copyright (c) 2000, 2014, 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> show databases;

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

| Database           |

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

| information_schema |

| lhr_test           |

| mysql              |

| performance_schema |

| test               |

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

5 rows in set (0.00 sec)

 

mysql> use lhr_test;

Database changed

mysql> create table t1(id int(10),name varchar(20));

Query OK, 0 rows affected (0.64 sec)

 

mysql> show tables;

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

| Tables_in_lhr_test |

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

| t1                 |

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

1 row in set (0.00 sec)

 

mysql> create table t2(id int(10));

Query OK, 0 rows affected (0.08 sec)

 

mysql> show tables;

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

| Tables_in_lhr_test |

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

| t1                 |

| t2                 |

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

2 rows in set (0.00 sec)

 

mysql> drop table t2;

Query OK, 0 rows affected (0.04 sec)

 

mysql> show tables;

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

| Tables_in_lhr_test |

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

| t1                 |

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

1 row in set (0.00 sec)

 

mysql>

 

一.1.4.3  檢視錶結構

1. desc tablename; or  describe tablename;

2. show create table tablename;

 

mysql> desc t1;

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

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

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

| id    | int(10)     | YES  |     | NULL    |       |

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

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

2 rows in set (0.08 sec)

 

mysql> show create table t1;

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

| Table | Create Table                                                                                                              |

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

| t1    | CREATE TABLE `t1` (

  `id` int(10) DEFAULT NULL,

  `name` varchar(20) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

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

1 row in set (0.03 sec)

 

mysql> show create table t1\G;

*************************** 1. row ***************************

       Table: t1

Create Table: CREATE TABLE `t1` (

  `id` int(10) DEFAULT NULL,

  `name` varchar(20) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1

1 row in set (0.00 sec)

 

ERROR:

No query specified

 

mysql>

 

一.1.4.4  插入資料

insert into tablename set id=1,name=lihuarong;

insert into tablename(id,name) values(2,zhangsan),(3,lisi);

 

mysql> insert into t1 set id=1,name='lihuarong';

Query OK, 1 row affected (0.06 sec)

 

mysql> insert into t1(id,name) values(2,'zhangsan'),(3,'lisi');

Query OK, 2 rows affected (0.00 sec)

Records: 2  Duplicates: 0  Warnings: 0

 

mysql>

 

一.1.4.5  查詢

mysql> select * from t1;

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

| id   | name      |

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

|    1 | lihuarong |

|    2 | zhangsan  |

|    3 | lisi      |

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

3 rows in set (0.03 sec)

 

mysql>

一.1.5  獲得幫助

 

mysql> ?

 

For information about MySQL products and services, visit:

   /

For developer information, including the MySQL Reference Manual, visit:

   http://dev.mysql.com/

To buy MySQL Enterprise support, training, or other products, visit:

  

 

List of all MySQL commands:

Note that all text commands must be first on line and end with ';'

?         (\?) Synonym for `help'.

clear     (\c) Clear the current input statement.

connect   (\r) Reconnect to the server. Optional arguments are db and host.

delimiter (\d) Set statement delimiter.

ego       (\G) Send command to mysql server, display result vertically.

exit      (\q) Exit mysql. Same as quit.

go        (\g) Send command to mysql server.

help      (\h) Display this help.

notee     (\t) Don't write into outfile.

print     (\p) Print current command.

prompt    (\R) Change your mysql prompt.

quit      (\q) Quit mysql.

rehash    (\#) Rebuild completion hash.

source    (\.) Execute an SQL script file. Takes a file name as an argument.

status    (\s) Get status information from the server.

tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.

use       (\u) Use another database. Takes database name as argument.

charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.

warnings  (\W) Show warnings after every statement.

nowarning (\w) Don't show warnings after every statement.

 

For server side help, type 'help contents'

 

mysql> select database();

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

| database() |

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

| mysql      |

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

1 row in set (0.00 sec)

 

 

 

一.1.6  總結

 

wps6D40.tmp 

mysql> show tables;

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

| Tables_in_lhr_test |

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

| t1                 |

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

1 row in set (0.00 sec)

 

mysql> create table T1(id int(5));

Query OK, 0 rows affected (0.06 sec)

 

mysql> show tables;

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

| Tables_in_lhr_test |

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

| T1                 |

| t1                 |

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

2 rows in set (0.00 sec)

 

mysql>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-2058841/,如需轉載,請註明出處,否則將追究法律責任。

相關文章