Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute mysql without sudo

I am trying to install wordpress on Odroid C2. However, wordpress could not access mysql.

enter image description here

So, I tried this.

enter image description here

If I execute mysql with sudo, it is OK. But, without sudo, I can't.

The OS of C2 is Ubuntu Mate 16.04, so I installed mariaDB instead of mysql.

I followed the guide of mariaDB installation.

How can I use mysql without sudo, and how can my wordpress access the DB.

like image 236
Karl Avatar asked May 14 '16 13:05

Karl


People also ask

How do I run MySQL from command line?

Launch the MySQL Command-Line Client. To launch the client, enter the following command in a Command Prompt window: mysql -u root -p . The -p option is needed only if a root password is defined for MySQL. Enter the password when prompted.

Should I run MySQL as root?

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.


2 Answers

try this to solve the problem:

Login in your DB

sudo mysql -u root -p

then make these modifications:

MariaDB []>use mysql;
MariaDB [mysql]>update user set plugin='' where User='root';
MariaDB [mysql]>flush privileges;
MariaDB [mysql]>exit

try login again without sudo

like image 131
Bernd Buffen Avatar answered Sep 19 '22 22:09

Bernd Buffen


This should be an serverfault.com issues. But anyway, go through this checklist

  1. Are you starting mysql with port other than 3306
  2. Check access of mysql client is o+rx , i.e. ls -la /usr/bin/mysql
  3. Did you grant user access other than "root" in mysqldb/mariadb. Mysql db may prevent you from using root@localhost if it is not running sudo

So if in case no 3, you must create a new user and grant access to it to solve this. i.e.

GRANT ALL ON <YOUR_WP_DATABASE_NAME>.* TO "wpuser"@"localhost" IDENTIFIED BY "somepassword"; 

Afterwards, try mysql using that user to confirm it works.

like image 40
mootmoot Avatar answered Sep 19 '22 22:09

mootmoot