赞
踩
mysql -uroot -p
- mysql> create user 'user'@'localhost' identified by '123456';
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> create user 'user'@'%' identified by '123456';
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> flush privileges;
- Query OK, 0 rows affected (0.00 sec)
- mysql> create database testdb default charset utf8 collate utf8_general_ci;
- Query OK, 1 row affected (0.00 sec)
- mysql> grant all privileges on `testdb`.* to 'user'@'%';
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> grant all privileges on `testdb`.* to 'user'@'localhost';
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> flush privileges;
- Query OK, 0 rows affected (0.00 sec)
注意: 此处以前我习惯性用
grant all privileges on `testdb`.* to 'user'@'%' identified by '123456';
但是数据库版本不同有时会不能成功执行,但是都支持
grant all privileges on `testdb`.* to 'user'@'%';
- mysql> exit
- Bye
mysql -uuser -p //输入密码123456
#bind-address = 127.0.0.1 #注释掉这一行并重启
② 需要对外/指定ip/ip段 开放3306端口
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。