MySQL 5.6.21下载安装之安装篇(二)

 

mysql安装

 

MySQL 5.6.21下载安装之安装篇(二)

1.1 Linux之下MySQL安装的三种方案的比较

具体内容参考这篇blog: http://blog.itpub.net/8183550/viewspace-680749/

 

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

一.1.1  mysql server 安装

 

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

MySQL 5.6.21下载安装之安装篇(二)MySQL 5.6.21下载安装之安装篇(二) 

2进入如下页面:(该图为页面最底部)

MySQL 5.6.21下载安装之安装篇(二)MySQL 5.6.21下载安装之安装篇(二) 

 

 

3下载完成解压该文件mysql-5.6.21-win32.zip

MySQL 5.6.21下载安装之安装篇(二)MySQL 5.6.21下载安装之安装篇(二) 

4打开文件mysql-5.6.21-win32

MySQL 5.6.21下载安装之安装篇(二)

5用记事本打开my-default.ini

MySQL 5.6.21下载安装之安装篇(二)MySQL 5.6.21下载安装之安装篇(二) 

 

修改

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

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

 

MySQL 5.6.21下载安装之安装篇(二) MySQL 5.6.21下载安装之安装篇(二)

完成上述步骤之后,很多用户开始使用MySQL,但会出现图示的错误。这是因为没有配置环境变量所致。

配置环境变量很简单:

我的电脑->属性->高级->环境变量

选择PATH,在其后面添加: 你的mysql bin文件夹的路径 (如:C:\Program Files\MySQL\MySQL Server 5.6\bin )

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

MySQL 5.6.21下载安装之安装篇(二) 

以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够),

输入:cd C:\Program Files\MySQL\MySQL Server 5.6\bin 进入mysql的bin文件夹(不管有没有配置过环境变量,也要进入bin文件夹,否则之后启动服务仍然会报错误2)

输入mysqld -install  (如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)

安装成功

MySQL 5.6.21下载安装之安装篇(二) 

 

安装成功后就要启动服务了,继续在cmd中输入:net start mysql(如图),服务启动成功!

MySQL 5.6.21下载安装之安装篇(二) 

mysqld -install  执行成功后就在系统的服务里添加了如下服务:

MySQL 5.6.21下载安装之安装篇(二) 

 

在cmd输入命令mysqladmin -uroot -p password (新密码)

Enter password:(初始密码没有,所以直接回车)

密码设置成功。

MySQL 5.6.21下载安装之安装篇(二) 

 

 

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

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

MySQL 5.6.21下载安装之安装篇(二)MySQL 5.6.21下载安装之安装篇(二)

 

 

进入如下页面:

 MySQL 5.6.21下载安装之安装篇(二)

 MySQL 5.6.21下载安装之安装篇(二) 解压mysql-workbench-community-6.2.3-win32-noinstall.zip

MySQL 5.6.21下载安装之安装篇(二)

打开文件D:\Program files\MySQL\MySQL Workbench 6.2.4 CE (winx64)

MySQL 5.6.21下载安装之安装篇(二) 

MySQL 5.6.21下载安装之安装篇(二) 

MySQL 5.6.21下载安装之安装篇(二) 

 

填写相应的条件就可以连接数据库了

 

 

安装成功的2个条件:

 

注 :安装MySQL workbench需安装

1.microsoft visual c++ 2013

2.MySQL 5.6.21下载安装之安装篇(二)

MySQL 5.6.21下载安装之安装篇(二) 

 

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.

· Microsoft .NET Framework 4 Client Profile

· Visual C++ Redistributable for Visual Studio 2013

 

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

下载安装包后将安装包利用ftp软件上传到server端,如图:

MySQL 5.6.21下载安装之安装篇(二) 

 

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

 

MySQL 5.6.21下载安装之安装篇(二) 

[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]#

 

基本情况下安装client和server就可以了。

[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

--&gt Running transaction check

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

--&gt 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 http://bugs.mysql.com/

 

The latest information about MySQL is available on the web at

 

  http://www.mysql.com

 

Support MySQL by buying support/licenses at http://shop.mysql.com

 

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 是默认的配置文件,还有其他的一些等等。。。

MySQL 5.6.21下载安装之安装篇(二) 

 

查看随机密码:

[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 ~]#

MySQL 5.6.21下载安装之安装篇(二) 

 

一.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

MySQL 5.6.21下载安装之安装篇(二) 

MySQL 5.6.21下载安装之安装篇(二) 

MySQL 5.6.21下载安装之安装篇(二) 

 

 

一.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:

   http://www.mysql.com/

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

   http://dev.mysql.com/

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

   https://shop.mysql.com/

 

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  总结

 

MySQL 5.6.21下载安装之安装篇(二) 

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>



上一篇:【linux-56】文件系统管理-df,du


下一篇:剑指 Offer 56 - I. 数组中数字出现的次数(C++) 分组异或