首页 > 数据库技术 > 详细

MySQL:Useful Commands

时间:2014-07-23 12:33:47      阅读:364      评论:0      收藏:0      [点我收藏+]

Start/Stop/Restart MySQL:
===========================
On Linux start/stop/restart from the command line:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
 
Some Linux flavours offer the service command too
service mysqld start
service mysqld stop
service mysqld restart

or
service mysql start
service mysql stop
service mysql restart

On OS X to start/stop/restart MySQL from the command line:
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

Connect:
===========================
mysql -h localhost -u myname -pMyPassword

Set Password:
===========================
First set: mysqladmin -u root -password root
then:
mysql> UPDATE mysql.user SET password=PASSWORD(’新密码’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;

Show current user:
===========================
mysql> select user();

Create Database:
===========================
mysql> create database openfire character set ‘utf8‘;

Show Databases:
===========================
mysql> show databases;

Use Database:
===========================
mysql> use database;

Show Tables:
===========================
mysql> show tables;

Empty database with root user
===========================
mysql> DROP DATABASE atomstore;
mysql> CREATE DATABASE atomstore;

Grant Permission
===========================
GRANT ALL PRIVILEGES ON * . * TO ‘newuser‘@‘localhost‘;
FLUSH PRIVILEGES;

Show table structure
===========================
SHOW [FULL] COLUMNS {FROM | IN} tbl_name [{FROM | IN} db_name]
    [LIKE ‘pattern‘ | WHERE expr]

Drop database
===========================
DROP DATABASE atomstore;

Drop table
===========================
DROP TABLE xxxxx;

Create table samples
===========================
create table if not exists `fchat`.`user` (
  `userId` int(7) not null auto_increment,
    `username` varchar(64) not null,
    `plainPassword` varchar(32) null,
    `encryptedPassword` varchar(255) null,
    `name` varchar(100) null,
    `email` varchar(100) null,
    `creationDate` datetime not null,
    `modificationDate` datetime not null,
    primary key(`userId`)
);

create table if not exists `fchat`.`tag` (
  `tagId` int(5) not null auto_increment,
  `tagName` varchar(64) not null,
  `userId` int(7) not null,
  primary key(`tagId`),
  foreign key (userId)
  references user(userId)
    on delete cascade
);

MySQL:Useful Commands,布布扣,bubuko.com

MySQL:Useful Commands

原文:http://www.cnblogs.com/ilovewindy/p/3850595.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!