mysql通过数据字典创建用户
mysql>
mysql> insert into mysql.user(host,user,password) values("localhost","itlife365userbase",password("123456"));
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 6
Current database: itlife365
Query OK, 1 row affected, 4 warnings (0.25 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into mysql.user(host,user,password) values('localhost','itlife365userbase2',password('123456'));
ERROR 1062 (23000): Duplicate entry 'localhost-itlife365userbas' for key 'PRIMARY'
mysql> insert into mysql.user(host,user,password) values('localhost','itlife365user2',password('123456'));
Query OK, 1 row affected, 3 warnings (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
注意:通过上面的实例看到,当用户名称过长的时候,系统会自动截断,比如itlife365userbase截断为itlife365userbas
这样就创建了一个名为:itlife365userbas密码为:123456(的)用户。
然后登录一下。
mysql>exit;
@>mysql -u itlife365userbas-p
@>输入密码
mysql>登录成功
mysql>
mysql> insert into mysql.user(host,user,password) values("localhost","itlife365userbase",password("123456"));
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 6
Current database: itlife365
Query OK, 1 row affected, 4 warnings (0.25 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into mysql.user(host,user,password) values('localhost','itlife365userbase2',password('123456'));
ERROR 1062 (23000): Duplicate entry 'localhost-itlife365userbas' for key 'PRIMARY'
mysql> insert into mysql.user(host,user,password) values('localhost','itlife365user2',password('123456'));
Query OK, 1 row affected, 3 warnings (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
注意:通过上面的实例看到,当用户名称过长的时候,系统会自动截断,比如itlife365userbase截断为itlife365userbas
这样就创建了一个名为:itlife365userbas密码为:123456(的)用户。
然后登录一下。
mysql>exit;
@>mysql -u itlife365userbas-p
@>输入密码
mysql>登录成功