mysql创建新用户步骤
1.创建用户
CREATE USER 'ying'@'%' identified by '123456';
2.赋予用户权限
GRANT ALL ON *.* TO 'ying'@'%' WITH GRANT OPTION;
刷新权限
flush PRIVILEGES;
4.查询用户
SELECT user,host,Password from mysql.`user` WHERE user='ying';
此处已经创建新用户完成!!!✌️✌️✌️
总结
一、mysql命令行执行sql文件注:提前将文件拷贝至当前目录下。1、登录mysql
mysql -u root -p ;
2、输入密码,选择数据库
use my_database;
3、执行sql文件。
source result.sql ;
二、统计数据库中表的数量
select count(table_name) from information_schema.`TABLES` where table_schema='my_database';
常见问题
问题一:后台登录mysql失败,提示‘ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)’,如下:
![b859bc6defd0f16a95d9c115fe168a97.png](https://i-blog.csdnimg.cn/blog_migrate/522ab3594414080cb17f585f0a59cd75.jpeg)
1.删除root其它用户,重置root用户的密码信息,并刷新权限
UPDATE mysql.`user` SET Password=Password('123456') WHERE `User`='root';
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush PRIVILEGES
2.重新登录成功
![f94747e63a453f463f6f50451755b2df.png](https://i-blog.csdnimg.cn/blog_migrate/69eb7cd61b7e566d95037f753e9e3686.jpeg)