1

I open a terminal and use sudo -s -u mysql. Now when i try to open a file, whose owner is mysql using gedit xyz.err, I get the error :

No protocol specified

** (gedit:23076): WARNING **: Could not open X display
No protocol specified
error: XDG_RUNTIME_DIR not set in the environment.

(gedit:23076): Gtk-WARNING **: cannot open display: :0

Is there some way to resolve this error ?

faizal
  • 111
  • 1
  • 1
  • 3
  • I think it might have something to do with the fact that mysql is a system account as opposed to being a user account. – faizal May 14 '14 at 17:59
  • I think it is related to the way is mounted your Drive Are you trying to execute it from an other partition? I got a very similar error and as far as I can tell is about the other drive (in my case) is not mounted with executable permission. Still investigating, just wanted to let you know. – elemer82 Jul 10 '14 at 19:08
  • Possible duplicate of [error: XDG\_RUNTIME\_DIR not set in the environment. Gtk-WARNING \*\*: cannot open display:](http://superuser.com/questions/987993/error-xdg-runtime-dir-not-set-in-the-environment-gtk-warning-cannot-open-d) – Scott - Слава Україні May 20 '16 at 18:55
  • 1
    See also [difference between `sudo` and `gksudo`](/q/202676/150988) and [Open a new terminal window on another user session](/q/539928/150988), and maybe also [Gtk-WARNING **: cannot open display](/q/898277/150988) and [Gtk-WARNING with display when using `sudo` in nx](/q/434368/150988). – Scott - Слава Україні May 20 '16 at 18:56

2 Answers2

0

You can get an interactive session by using su - mysql, and then run gedit. Works for me.

man sudo doesn't give any details, but it could be that the default shell launched with -s is very limited.

l0b0
  • 7,171
  • 4
  • 33
  • 54
  • my intention is a bit different. I want to keep a terminal open that uses the mysql account previliges. That is why i use the "sudo -s -u mysql". So that any further commands don't require me to use sudo. Using gksudo to open gedit every time does not really serve my purpose. – faizal May 14 '14 at 16:16
  • Using "su - mysql" and then gedit, as suggested in your edited answer, also gives me the same error. – faizal May 14 '14 at 16:55
-1

You're looking in the wrong place, running mysql as (system) user mysql won't solve anything.

mysql is a client program, the authentication to the server, run by mysqld, is made on the connection (tcpdump port 3306 to make it clear).

Therefore, you can launch mysql with any "system" user, like:

$ mysql -u root -p localhost

Give the admin ("root") password when prompted, and then you should see this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 240
Server version: 5.5.38-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

...and there you go!

digitxp
  • 14,432
  • 9
  • 56
  • 76
  • Sorry for the misleading OP, but it has nothing to do with the `mysql` program. It is to do with opening a file in `gedit` with a particular account, which happens to be `mysql`. – faizal Aug 09 '14 at 11:55