如何登录mysql并从linux终端查询数据库 [英] how to log in to mysql and query the database from linux terminal
问题描述
我正在使用debian linux. 我有一台安装了mysql的Linux机器. 我可以使用root用户以及其他用户身份登录到我的linux计算机. 我可以使用sqlyog从Windows计算机连接到Linux计算机上的mysql数据库. 现在我只想使用Linux终端在Linux机器上执行查询
I am using debian linux. I have a linux machine on which mysql is install. I can log in to my linux machine using root user as well as other user. I can connect to mysql database on linux machine from windows machine using sqlyog. Now I want to execute queries on linux machine only using linux terminal
我在终端上尝试了以下操作
I tried some following things on terminal
我去了根目录,然后去了/var/lib目录
I went to root directory then I went to /var/lib directory
我在终端上运行以下命令
I run following commands on terminal
mysqladmin -u root -p
mysqladmin -u root -ppassword
每次我收到以下错误消息
everytime I have get following error message
错误1045(28000)拒绝访问 用户'root'@'localhost'(使用 密码NO)
ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)
请指导我关注
- 如何在linux终端中获取mysql提示符?
- 如何从linux终端停止mysql服务器?
- 如何从linux终端启动mysql服务器?
- 如何在linux终端中获取mysql提示符?
- 如何从Linux终端登录mysql服务器?
- 如何解决以下错误?
错误1045(28000)拒绝访问 用户'root'@'localhost'(使用 密码NO)
ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)
请给我以上问题的解决方案. 谢谢
Please give me solutions for above question. Thank You
推荐答案
1.-如何在Linux终端中获取mysql提示符?
mysql -u root -p
在Enter password:
提示符下,输入root的密码:)
At the Enter password:
prompt, well, enter root's password :)
您可以通过键入mysql --help
或在在线手册.
2.如何从Linux终端停止mysql服务器?
这取决于.基于Red Hat的发行版具有service
命令:
It depends. Red Hat based distros have the service
command:
service mysqld stop
其他发行版需要直接调用初始化脚本:
Other distros require to call the init script directly:
/etc/init.d/mysqld stop
3.如何从Linux终端启动mysql服务器?
与#2相同,但具有start
.
4.如何在Linux终端中获取mysql提示符?
与#1相同.
5.如何从Linux终端登录mysql服务器?
与#1相同.
6.如何解决以下错误?
与#1相同.
这篇关于如何登录mysql并从linux终端查询数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!