码迷,mamicode.com
首页 > 数据库 > 详细

MySQL:Useful Commands

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

标签:os   io   art   for   re   c   

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

标签:os   io   art   for   re   c   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!