当前位置:网站首页>【日记】mysql基本操作
【日记】mysql基本操作
2022-08-04 17:18:00 【ttyt1217】
今天学习了mysql数据库相关操作,用的是目前最新的mysql8.0.20版本,有些语句和老版本不一样,需要注意。
用户登录DB:
mysql -u root -p
查看mysql版本
SELECT @@VERSION
创建数据库用户:
create user 'user****'@'localhost' identified by '*****password';
此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。
查看数据库用户:
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
更新数据库用户密码:
update mysql.user set authentication_string='*****' where user='user*****';
删除数据库用户:
Delete FROM mysql.user Where User='user****' and Host='localhost';
以上操作后要用下面语句刷新MySQL的系统权限相关表,否则会出现拒绝访问:
flush privileges;
授予用户访问数据库的全部权限
grant all privileges on `xxxDB`.* to 'apicaller'@'localhost' with grant option;
注意上面关键字 xxxDB的外部使用反引号` `括起来的。
nodejs执行app.js报这个错时,
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server;
意为mysql8.0以上加密方式,Node还不支持,需要在mysql执行以下命令:
alter user 'apicaller'@'localhost' identified with mysql_native_password by '****';
查看DB
show databases;
查看表
show tables;
边栏推荐
猜你喜欢
随机推荐
字节二面被问到mysql事务与锁问题,我蚌埠住了
Selenium Webdriver驱动自管理
抖音最重要的接口——item_search_video-根据关键词获取视频列表
提高图片清晰度的快速方法?
dotnet core 隐藏控制台
.NET云原生应用发展论坛--8月7日邀你一起云上探索
谷歌开发者社区推荐:《Jetpack Compose 从入门到实战》新书上架,带你踏上 Compose 开发之旅~
Boost library study notes (1) Installation and configuration
How to convert an int attribute into a string in the json format returned by the Go language gin framework?
To eliminate asynchronous callbacks, it has to be async-await
R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化柱状图、color参数指定柱状图的边框的色彩
IDEA以多端口启动同一个服务项目
The second step through MySQL in four steps: MySQL index learning
SAP ABAP SteammPunk 蒸汽朋克的最新进展 - 嵌入式蒸汽朋克
dotnet remoting 抛出异常
【小程序】实现发动态功能
为什么买域名必须实名认证?这样做什么原因?
安装失败怎么办
在VMD上可视化hdf5格式的分子轨迹文件
LeetCode Question of the Day - 1403. Minimum Subsequence in Non-Increasing Order