Mysql數(shù)據(jù)類型
字符類型
字符串類型指CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT、ENUM和SET
| 類型 | 大小 | 用途 |
|---|---|---|
| CHAR | 0-255字節(jié) | 定長(zhǎng)字符串 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
| 類型 | 大小 | 用途 |
Mysql創(chuàng)建用戶與授權(quán)
- 創(chuàng)建用戶
mysql> CREATE USER 'mike'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
- 授權(quán)
命令:GRANT privileges ON databasename.tablename TO 'username'@'host'
grant all PRIVILEGES on *.* to root@'%' identified by '123456';
| 權(quán)限名稱 | 說(shuō)明 |
|---|---|
| ALTER | Allows use of ALTER TABLE |
| ALTER ROUTINE | Alters or drops stored routines |
| CREATE | Allows use of CREATE TABLE |
| CREATE ROUTINE | Creates stored routines |
| CREATE TEMPORARY TABLE | Allows use of CREATE TEMPORARY TABLE |
| CREATE USER | Allows use of CREATE USER DROP USER RENAME USER and REVOKE ALL PRIVILEGES |
| CREATE VIEW | Allows use of CREATE VIEW |
| DELETE | Allows use of DELETE |
| DROP | Allows use of DROP TABLE |
| EXECUTE | Allows the user to run stored routines. |
| FILE | Allows use of SELECT ... INTO OUTFILE and LOAD DATA INFILE >. |
| INDEX | Allows use of CREATE INDEX and DROP INDEX |
| INSERT | Allows use of INSERT |
| LOCK TABLES | Allows use of LOCK TABLES on tables for which the user also has SELECT privileges |
| PROCESS | Allows use of SHOW FULL PROCESSLIST |
| RELOAD | Allows use of FLUSH |
| REPLICATION | Allows the user to ask where slave or master |
| CLIENT | servers are |
| REPLICATION SLAVE | Needed for replication slaves |
| SELECT | Allows use of SELECT |
| SHOW DATABASES | Allows use of SHOW DATABASES |
| SHOW VIEW | Allows use of SHOW CREATE VIEW |
| SHUTDOWN | Allows use of mysqladmin shutdown |
| SUPER | Allows use of CHANGE MASTER , KILL , PURGE MASTER LOGS , and SET GLOBAL SQL statements. Allows mysqladmin debug command. Allows one extra connection to be made if maximum connections are reached. |
| UPDATE | Allows use of UPDATE |
| USAGE | Allows connection without any specific privileges. |
- 設(shè)置與更改用戶密碼
命令:SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');如果是當(dāng)前登陸用戶用SET PASSWORD = PASSWORD("newpassword");
修改當(dāng)前登錄用戶的密碼
SET PASSWORD = PASSWORD("newpassword");
root用戶修改其他用戶密碼 貌似這種方式會(huì)報(bào)一個(gè)警告
mysql> update mysql.user set authentication_string=password("222222") where User="mike" and Host="localhost";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
- 刪除用戶與權(quán)限
drop user 用戶名@’%’;
drop user 用戶名@ localhost;
- mysql 查看狀態(tài) 開(kāi)啟 關(guān)閉
查看是否已開(kāi)啟
ubuntu@VM-0-10-ubuntu:~$ ps -ef|grep mysqld
mysql 25240 1 0 14:21 ? 00:00:02 /usr/sbin/mysqld
ubuntu 30182 28796 0 16:07 pts/0 00:00:00 grep --color=auto mysqld
開(kāi)啟
ubuntu@VM-0-10-ubuntu:~$ service mysql start
關(guān)閉
ubuntu@VM-0-10-ubuntu:~$ service mysql stop