1

I've installed mysql-server and mysql-workbench packets. Everything seems to work fine, but when I try to connect to a database through mysql-workbench I can't, except if I start mysql-workbench via cli with the command

sudo mysql-workbench

I checked other posts that said that this behaviour depends on the different type of authentication given to the mysql root user (auth_socket), but also if I change the authentication for the root user to mysql_native_pasword, I'm able to connect to the database server only if I start Workbench as super user.

MKay
  • 935
  • check this https://askubuntu.com/a/793750/696495 – Arun Nov 21 '19 at 15:07
  • Thanks @Arun, yet tried... Setting up a different user both with auth_sock and mysql_native_password authentication does not work for me. I still need to sudo mysql-workbench from cli to get it working. – MKay Nov 21 '19 at 15:11
  • Workaround: get into the /etc/sudoers file and allow your normal user to use this command. Then you don't have to use sudo anymore. For the user there is no difference. Also you can add more then one user to allow this command on this server, if neccessary. – s1mmel Nov 27 '19 at 11:50
  • might be a double....check the second answer

    see here https://askubuntu.com/questions/773446/unable-to-connect-via-mysql-workbench-to-localhost-in-ubuntu-16-04-passwordless

    – s1mmel Nov 27 '19 at 19:30

2 Answers2

0

On Linux, for installations performed using a MySQL repository or RPM packages, the MySQL server mysqld should be started by the local mysql operating system user. Starting by another operating system user is not supported by the init scripts that are included as part of the MySQL repositories.

On Unix (or Linux for installations performed using tar.gz packages) , the MySQL server mysqld can be started and run by any user. However, you should avoid running the server as the Unix root user for security reasons. To change mysqld to run as a normal unprivileged Unix user user_name, you must do the following:

Stop the server if it is running (use mysqladmin shutdown). Change the database directories and files so that user_name has privileges to read and write files in them (you might need to do this as the Unix root user):

shell> chown -R user_name /path/to/mysql/datadir

If you do not do this, the server will not be able to access databases or tables when it runs as user_name.

If directories or files within the MySQL data directory are symbolic links, chown -R might not follow symbolic links for you. If it does not, you will also need to follow those links and change the directories and files they point to.

Start the server as user user_name. Another alternative is to start mysqld as the Unix root user and use the --user=user_name option. mysqld starts, then switches to run as the Unix user user_name before accepting any connections.

To start the server as the given user automatically at system startup time, specify the user name by adding a user option to the [mysqld] group of the /etc/my.cnf option file or the my.cnf option file in the server's data directory. For example:

[mysqld]
user=user_name

If your Unix machine itself is not secured, you should assign passwords to the MySQL root account in the grant tables. Otherwise, any user with a login account on that machine can run the mysql client with a --user=root option and perform any operation. (It is a good idea to assign passwords to MySQL accounts in any case, but especially so when other login accounts exist on the server host.)

Text comes from https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html. I'm not sure if this is referring to MySQL users or Ubuntu users. I hope this at least helps

ut793
  • 55
-1

you have to login to mysql and grant permission for the standard user

mysql> select * from mysql.user;

this will list users,

Follow this post to Set Privileges

How to Grant All Privileges on a Database in MySQL