MYSQL的安装
环境:redhat6.8服务器
版本:mysql5.6.39版本
下载地址:https://dev.mysql.com/downloads/mysql/5.6.html
解压并用rpm安装
查看mysql的版本命令:$mysql -V
启动mysql命令:$service mysql start
MYSQL的目录信息
默认数据库所在目录:/var/lib/mysql 备注:存放数据库,即datadir目录,sock文件,pid文件
默认加载配置文件:/etc/my.cnf 备注:可以从示例配置文件中拷贝过来,修改其中的内容
[mysqld]
port=3306 //用于远程连接的端口
#datadir=/var/lib/mysql/ //默认的数据目录
datadir=/home/mysql/ //修改后的数据目录
socket=/var/lib/mysql/mysql.sock //存放socket文件
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
max_connections=16384 //最大连接数,sysbench需要用
其他文件所在目录:/usr/share/mysql 备注:存放示例配置文件my-default.cnf等
MYSQL的使用
命令:
查看mysql版本:mysql --version
[root@stor37 cmm]# mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
进入mysql命令:$mysql -u 用户名 -p 密码
[root@stor37 cmm]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, 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;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
mysql>
新建数据库:>create database [数据库名称];
mysql> create database newtwo;
Query OK, 1 row affected (0.00 sec)
mysql>
删除数据库:>drop databse [数据库名称];
mysql> drop database newtwo;
Query OK, 0 rows affected (0.02 sec)
mysql>
使用数据库:>use [数据库名称];
mysql> use newone;
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;