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
);
相关文章
- 08-18Useful JVM Flags – Part 8 (GC Logging)
- 08-18LaTeX编译参考文献“I found no \citation commands---while reading file”问题
- 08-18Some shell commands
- 08-18【python2】commands模块getstatusoutput函数的小问题
- 08-18Ansible — Ad-Hoc Commands
- 08-18Commands for IP
- 08-18windows commands
- 08-18[Bash] Chain Commands with Pipes and Redirect Output in Bash
- 08-18Cypress系列(63)- 使用 Cypress.Commands 完成 Custom Commands 自定义命令
- 08-18How To Add Custom Build Steps and Commands To setup.py