$ mysql -u user -p
As of MySQL 5.7.6, use this statement:
mysql> SELECT User, Host, HEX(authentication_string) FROM mysql.user;
Before MySQL 5.7.6, use this statement:
mysql> SELECT User, Host, Password FROM mysql.user;
2.查看用户的权限
1
mysql > SHOW GRANTS FOR 'username'@'localhost';
3.为用户添加操作某个数据库的权限
12
mysql > GRANT select, insert, update, delete, index, alter, create ON db2.* TO 'jeffrey'@'localhost';
mysql > GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER ON `xiao_chun`.* TO `xiaochun`@`localhost`;
4.Default options are read from the following files in the given order:
/etc/my.cnf
/etc/mysql/my.cnf
/usr/local/mysql/etc/my.cnf
~/.my.cnf
5.
123456
mysql > CREATE TABLE IF NOT EXISTS categories (
id SMALLINT NOT NULL AUTO_INCREMENT,
category VARCHAR(30) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY category (category)
)ENGINE = MyISAM DEFAULT CHARSET = utf8;
VARCHAR(30):can hold up to 30 characters.
A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. For all engines, a UNIQUE index permits multiple NULL values for columns that can contain NULL.