centos7上mysql的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cds86333774/article/details/51165830

1 查看mysql的安装情况

[dustin@master ~]$ yum list installed mysql*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.01link.hk
 * extras: centos.01link.hk
 * updates: centos.01link.hk
Installed Packages
mysql-community-client.x86_64           5.6.30-2.el7          @mysql56-community
mysql-community-common.x86_64           5.6.30-2.el7          @mysql56-community
mysql-community-libs.x86_64             5.6.30-2.el7          @mysql56-community
mysql-community-release.noarch          el7-5                 installed         
mysql-community-server.x86_64           5.6.30-2.el7          @mysql56-community
[dustin@master ~]$ 
[dustin@master ~]$ rpm -qa | grep mysql*
mysql-community-client-5.6.30-2.el7.x86_64
mysql-community-common-5.6.30-2.el7.x86_64
mysql-community-release-el7-5.noarch
mysql-community-libs-5.6.30-2.el7.x86_64
mysql-community-server-5.6.30-2.el7.x86_64

如果还没有安装mysql,可以参考博文:http://blog.csdn.net/cds86333774/article/details/51132532



2 启动/关闭 mysql

启动

旧:

[dustin@master ~]$ service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
[dustin@master ~]$ 

新:

$ systemctl start mysqld

关闭

旧:

[dustin@master ~]$ service mysqld stop
Redirecting to /bin/systemctl stop  mysqld.service
[dustin@master ~]$ 

新:

systemctl stop  mysqld


3 登录

[dustin@master ~]$ mysql -u dustin -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.30 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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 |
| hive2              |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.27 sec)

mysql> use hive2;
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
mysql> show tables;
+---------------------------+
| Tables_in_hive2           |
+---------------------------+
| AUX_TABLE                 |
| BUCKETING_COLS            |
| CDS                       |
| COLUMNS_V2                |
| COMPACTION_QUEUE          |
| COMPLETED_COMPACTIONS     |
| COMPLETED_TXN_COMPONENTS  |
| DATABASE_PARAMS           |
| DBS                       |
| DB_PRIVS                  |
| DELEGATION_TOKENS         |
| FUNCS                     |
| FUNC_RU                   |
| GLOBAL_PRIVS              |
| HIVE_LOCKS                |
| IDXS                      |
| INDEX_PARAMS              |
| MASTER_KEYS               |
| NEXT_COMPACTION_QUEUE_ID  |
| NEXT_LOCK_ID              |
| NEXT_TXN_ID               |
| NOTIFICATION_LOG          |
| NOTIFICATION_SEQUENCE     |
| NUCLEUS_TABLES            |
| PARTITIONS                |
| PARTITION_EVENTS          |
| PARTITION_KEYS            |
| PARTITION_KEY_VALS        |
| PARTITION_PARAMS          |
| PART_COL_PRIVS            |
| PART_COL_STATS            |
| PART_PRIVS                |
| ROLES                     |
| ROLE_MAP                  |
| SDS                       |
| SD_PARAMS                 |
| SEQUENCE_TABLE            |
| SERDES                    |
| SERDE_PARAMS              |
| SKEWED_COL_NAMES          |
| SKEWED_COL_VALUE_LOC_MAP  |
| SKEWED_STRING_LIST        |
| SKEWED_STRING_LIST_VALUES |
| SKEWED_VALUES             |
| SORT_COLS                 |
| TABLE_PARAMS              |
| TAB_COL_STATS             |
| TBLS                      |
| TBL_COL_PRIVS             |
| TBL_PRIVS                 |
| TXNS                      |
| TXN_COMPONENTS            |
| TYPES                     |
| TYPE_FIELDS               |
| VERSION                   |
+---------------------------+
55 rows in set (0.00 sec)

mysql> exit;
Bye


4 启动/禁止自动启动

查看其是否可以自动启动

这里写图片描述

自动启动

$ systemctl enable mysqld

这里写图片描述

禁止

这里写图片描述



systemctl 命令详情请参考博文:http://blog.csdn.net/cds86333774/article/details/51165361

猜你喜欢

转载自blog.csdn.net/cds86333774/article/details/51165830