登 录mysql

 mysql -u root -p

创建允许本地 IP访问localhost的Mysql数据库时出错

 create user 'lijing'@'localhost' identified by '147258369';

ERROR 1396 (HY000): Operation CREATE USER failed for 'lijing'@'localhost'

 出错原因:

Assume the user is there, so drop the user
After deleting the user, there is need to flush the mysql privileges
Now create the user.

以下解决办法:

创建允许本地 IP访问localhost的Mysql数据库:

 drop user 'lijing'@'localhost';

 flush privileges;刷新系统权限表)

 create user 'lijing'@'localhost' identified by '147258369';

创建允许外网IP访问数据库lijing,本命令包含上面的命令,是所有的IP都可以访问该数据库

create user 'lijing'@'%' identified by '147258369';258369';

 创建成功后查询创建的用户是否成功

 select host,user,authentication_string from mysql.user;

创建一个新的数据库,并使用show databases命令查看数据库是否创建OK

 create database lijingdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

show databases;