设为首页 收藏本站
查看: 806|回复: 0

[经验分享] MySQL 5.6.21下载安装之安装篇(二)

[复制链接]

尚未签到

发表于 2015-12-22 12:00:44 | 显示全部楼层 |阅读模式
  
mysql安装
  
DSC0000.gif
  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/
   DSC0001.png DSC0002.png  
  2进入如下页面:(该图为页面最底部)
   DSC0003.png DSC0004.png  
   
   
  3下载完成解压该文件mysql-5.6.21-win32.zip
   DSC0005.png DSC0006.png  
  4打开文件mysql-5.6.21-win32
   DSC0007.png
  5用记事本打开my-default.ini
   DSC0008.png DSC0009.png  
   
  修改
  basedir=C:\Program Files\MySQL\MySQL Server 5.6(mysql所在目录)
  datadir=C:\Program Files\MySQL\MySQL Server 5.6\data (mysql所在目录\data)
   
DSC00010.png   DSC00011.png
  完成上述步骤之后,很多用户开始使用MySQL,但会出现图示的错误。这是因为没有配置环境变量所致。
  配置环境变量很简单:
  我的电脑->属性->高级->环境变量
  选择PATH,在其后面添加: 你的mysql bin文件夹的路径 (如:C:\Program Files\MySQL\MySQL Server 5.6\bin )
  PATH=.......;C:\Program Files\MySQL\MySQL Server 5.6\bin (注意是追加,不是覆盖)
DSC00012.png  
  以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够),
  输入:cd C:\Program Files\MySQL\MySQL Server 5.6\bin进入mysql的bin文件夹(不管有没有配置过环境变量,也要进入bin文件夹,否则之后启动服务仍然会报错误2)
  输入mysqld -install  (如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)
  安装成功
DSC00013.png  
   
  安装成功后就要启动服务了,继续在cmd中输入:net start mysql(如图),服务启动成功!
DSC00014.png  
  mysqld -install  执行成功后就在系统的服务里添加了如下服务:
DSC00015.png  
   
  在cmd输入命令mysqladmin -uroot -p password (新密码)
  Enter password:(初始密码没有,所以直接回车)
  密码设置成功。
DSC00016.png  
   
   
一.1.1  mysql-workbench-community-6.2.3-win32-noinstall
  登录http://dev.mysql.com/downloads/ 
   DSC00017.png DSC00018.png
  
  
  进入如下页面:
    DSC00019.png
    DSC00020.png 解压mysql-workbench-community-6.2.3-win32-noinstall.zip
   DSC00021.png
  打开文件D:\Program files\MySQL\MySQL Workbench 6.2.4 CE (winx64)
DSC00022.png  
DSC00023.png  
DSC00024.png  
   
  填写相应的条件就可以连接数据库了
   
  
  安装成功2个条件:
   
   :安装MySQL workbench需安装
  1.microsoft visual c++ 2013
  2. DSC00025.png
DSC00026.png  
   
  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端,如图:
DSC00027.png  
   
  MD5值校验:
  [iyunv@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
  [iyunv@rhel6_lhr Downloads]#
   
   
  解压缩之后:
   
  unzip MySQL Database 5.6.21 RPM for Oracle Linux  RHEL 6 x86 (64bit).zip
   
DSC00028.png  
  [iyunv@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
  [iyunv@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             
  [iyunv@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
  [iyunv@rhel6_lhr Downloads]#
   
  基本情况下安装client和server就可以了。
  [iyunv@rhel6_lhr Downloads]# rpm -ivh MySQL-client-advanced-5.6.21-1.el6.x86_64.rpm
  Preparing...                ########################################### [100%]
     1:MySQL-client-advanced  ########################################### [100%]
  [iyunv@rhel6_lhr Downloads]#
   
  采用yum安装:
  [iyunv@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                                                                             >
  ===============================================================================================================================================================================================================================================================================
  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>
  Installed>
  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,>
  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>
  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>
  2014-11-27 09:56:49 356 [Note] InnoDB: Setting log file ./ib_logfile1>
  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,>
  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!
  [iyunv@rhel6_lhr Downloads]#
  以上红色字体大概是说一个随机密码已经设置了,'/root/.mysql_secret'可以看到,/usr/my.cnf 是默认的配置文件,还有其他的一些等等。。。
DSC00029.png  
   
  查看随机密码:
  [iyunv@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
   
  [iyunv@rhel6_lhr ~]#
DSC00030.png  
   
一.1.1  启动服务
  /etc/init.d/mysql start  或  service mysql start
   
  [iyunv@rhel6_lhr ~]# service mysql start
  Starting MySQL... SUCCESS!
  [iyunv@rhel6_lhr ~]#
   
  修改密码,执行/root/mysql_secure_installation
   
  [iyunv@rhel6_lhr ~]# pwd
  /root
  [iyunv@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...
  [iyunv@rhel6_lhr ~]#
   
一.1.2  连接mysql
DSC00031.png  
DSC00032.png  
DSC00033.png  
   
   
一.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 
   
  [iyunv@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>
  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
  [iyunv@rhel6_lhr ~]# mysql -p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection>
  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;
   
  [iyunv@rhel6_lhr ~]# mysql -p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection>
  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;
   
  [iyunv@rhel6_lhr ~]# mysql -p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection>
  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 |
  +-------+-------------+------+-----+---------+-------+
  |>
  | 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>lihuarong;
  insert into tablename(id,name) values(2,zhangsan),(3,lisi);
   
  mysql> insert into t1 set>
  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;
  +------+-----------+
  |>
  +------+-----------+
  |    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  总结
   
DSC00034.png  
  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>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-154742-1-1.html 上篇帖子: MySQL索引性能测试 下篇帖子: MySQL 5.6.21下载安装之下载篇(一)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表