如何从linux终端登录mysql并查询数据库 [英] how to log in to mysql and query the database from linux terminal

查看:72
本文介绍了如何从linux终端登录mysql并查询数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 debian linux.我有一台安装了 mysql 的 linux 机器.我可以使用 root 用户和其他用户登录我的 linux 机器.我可以使用sqlyog从windows机器连接到linux机器上的mysql数据库.现在我只想使用 linux 终端在 linux 机器上执行查询

我在终端上尝试了以下一些东西

我去根目录然后我去/var/lib目录

我在终端上运行以下命令

mysqladmin -u root -pmysqladmin -u root -ppassword

每次我收到以下错误消息

<块引用>

错误 1045 (28000) 拒绝访问用户 'root'@'localhost'(使用密码否)

请指导我跟随

  1. 如何在 linux 终端中获得 mysql 提示?
  2. 如何从 linux 终端停止 mysql 服务器?
  3. 如何从 linux 终端启动 mysql 服务器?
  4. 如何在 linux 终端中获得 mysql 提示?
  5. 如何从 linux 终端登录到 mysql 服务器?
  6. 如何解决以下错误?

<块引用>

错误 1045 (28000) 拒绝访问用户 'root'@'localhost'(使用密码否)

请给我以上问题的解决方案.谢谢

解决方案

1.- 如何在 linux 终端获得 mysql 提示?

mysql -u root -p

Enter password: 提示下,输入root 的密码:)

您可以通过键入 mysql --help 或在 在线手册.

2.如何从 linux 终端停止 mysql 服务器?

这取决于.基于 Red Hat 的发行版具有 service 命令:

服务mysqld停止

其他发行版需要直接调用init脚本:

/etc/init.d/mysqld 停止

3.我如何从 linux 终端启动 mysql 服务器?

与#2 相同,但带有 start.

4.linux终端如何获取mysql提示?

与#1 相同.

5.如何从linux终端登录mysql服务器?

与#1 相同.

6.如何解决以下错误?

与#1 相同.

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

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

ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)

please guide me for following

  1. How do I get mysql prompt in linux terminal?
  2. How I stop the mysql server from linux terminal?
  3. How I start the mysql server from linux terminal?
  4. How do I get mysql prompt in linux terminal?
  5. How do I login to mysql server from linux terminal?
  6. How do I solve following error?

ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)

Please give me solutions for above question. Thank You

解决方案

1.- How do I get mysql prompt in linux terminal?

mysql -u root -p

At the Enter password: prompt, well, enter root's password :)

You can find further reference by typing mysql --help or at the online manual.

2. How I stop the mysql server from linux terminal?

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. How I start the mysql server from linux terminal?

Same as #2, but with start.

4. How do I get mysql prompt in linux terminal?

Same as #1.

5. How do I login to mysql server from linux terminal?

Same as #1.

6. How do I solve following error?

Same as #1.

这篇关于如何从linux终端登录mysql并查询数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆