MYSQL常用命令

LINUX下安装命令

Debian or Ubuntu

sudo apt-get install mysql mysql-server

** CentOs**

sudo apt-get install mysql mysql-server

添加root用户名密码

mysqladmin -u root -p password 'newpwd'
#或者mac os下
usr/local/mysql/bin/mysqladmin -u -root -p 'newpwd'

登录mySQL

mysql -u root -p #usr/local/mysql/bin/mysql -u root -p #MAC OS下
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2247
Server version: 5.1.73-log MySQL Community Server (GPL)

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>

mySQL配置文件路径

windows : C:\Program Fils\MySQL Server 5.6\my-defaut
Linux: /etc/my.cnf
MAC:/usr/local/mysql/my.cnf

修改配置文件

[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

default-character-set = utf8

[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
log-error=/alidata/log/mysql/error.log
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

character-set-server = utf8
default-storage-engine = INNODB

重启MySQL

windows重启windows服务
LINUX/etc/init.d/mysql restart
MAC: sudo /Library/Startupltems/MySQLCOM/MYSQKCIN restart

查看MySQL是否运行

root@host# ps -ef | grep mysqld

####关闭MySQL

root@host# mysqladmin -u root -p shutdown
Enter password: ******

添加和删除命令

DB数据库缩写
查看当前DB:

show databases

添加DB:

create database gc;

删除DB:

drop database gc;

注意 mySQL命令已;为结束符,而不是回车

MYSQL数据类型

相关教程链接

相关资料

阿里云学习视频
MySQL 教程

发表评论