Last active
September 5, 2015 14:34
-
-
Save huacnlee/505642 to your computer and use it in GitHub Desktop.
MySQL 常用命令
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- MySQL 创建超级用户 创建用户,并有localhost下所有数据库的超级权限 | |
mysql> grant all on *.* to monster@localhost identified by "123456"; | |
mysql> flush privileges; | |
- 删除用户 | |
mysql> use mysql; | |
mysql> delete from user where user = 'monster'; | |
- 创建 Repl 的用户 | |
master> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY '123456'; | |
master> flush privileges; | |
- Master 上面查看 Bin-log 状态 | |
master> FLUSH TABLES WITH READ LOCK; | |
master> SHOW MASTER STATUS; | |
+------------------+----------+--------------+------------------+ | |
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | | |
+------------------+----------+--------------+------------------+ | |
| mysql-bin.000003 | 239 | | | | |
+------------------+----------+--------------+------------------+ | |
- 在 Slave 上面连接上 Master | |
slave>CHANGE MASTER TO MASTER_HOST='11.11.11.11', MASTER_USER='repl', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000005', MASTER_LOG_POS=267; | |
slave> START SLAVE; | |
- 解锁上面的的 Lock; | |
master> UNLOCK TABLES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment