首页 热点资讯 义务教育 高等教育 出国留学 考研考公
您的当前位置:首页正文

mysql基本语法

2024-12-21 来源:华佗小知识

mysql的启动重启命令

sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart

可以设置vi ~/.bash_profile,记得source ~/.bash_profile

alias mysqlst='sudo /usr/local/MySQL/support-files/mysql.server start'
alias mysqlsp='sudo /usr/local/MySQL/support-files/mysql.server stop'

基本语法:

// 登录本地
mysql -u root -p 

// 远程登录
mysql -u {username} -p{password} -h {remote server ip} -P {port} {DB name}

source <.sql文件路径> // 导入.sql文件

mysqldump -u root -p 数据库名>sql_name.sql // 导出.sql文件到当前路径下

show databases;

CREATE DATABASE 数据库名;

drop database <数据库名>;

use 数据库名;

show tables;

desc  table_name; // 查看表结构

CREATE TABLE table_name (column_name column_type);

CREATE TABLE IF NOT EXISTS `runoob_tbl`(
   `runoob_id` INT UNSIGNED AUTO_INCREMENT,
   `runoob_title` VARCHAR(100) NOT NULL,
   `runoob_author` VARCHAR(40) NOT NULL,
   `submission_date` DATE,
   PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE table_name ;

INSERT INTO table_name ( field1, field2,...fieldN )
                       VALUES
                       ( value1, value2,...valueN );

推荐阅读

显示全文