Where did I go wrong... again?

I’m getting a “[Warning] Access denied for user ‘root’@‘localhost’ (using password: NO)” message in the /var/log/mysql/error.log

I’ve been fighting a LEARNING battle with NextCloud for a while now. Seems that I’m getting further along every day though.

Had no guidance what users to make other than root (default) and an admin user; and was confused by which “user” to use when setting up NextCloud / mySQL’s nextcloud database.

I can successfully log into mySQL as either root or admin with the appropriate password, and the admin password (in clear-text) is correct in the nextcloud/config/config.php

I’m just at a loss of where / how to fix the error that I’m getting now.

It’s causing me to be unable to access NextCloud at all. Give me a “404 Not Found” page at *.org/index.php/login – well, it’s stopping me from going any further to find out what is giving me the error, if it’s not.

Just looking for a few suggestions of where to start looking. Thanks!

Using NGINX, MariaDB, PHP7.4, with SSL on Ubuntu 20.04 (no GUI)

I think you get normally not this error from your nextcloud because your nextcloud (config/config.php) users not the user “root” and uses a passoword (not: “using passowrd:NO”).

I am at the exact same point!
I don’t know where I went wrong, especially since I am new to Linux/nextcloud…
basically parroting the commands I am told to use in the installation guides…
One day, I hope I’ll “understand” what I am doing LOL
In the meantime, I hope G-Wiz and I find the answer :slight_smile:

It is important to understand what you are doing. So to help as I can I will try and explain for you.
Read along to the end as the beginning is already working for you.

I’m old school so I use all the defaults where possible. Apache Web server has been there long before the made nginx and when I see some post from nginx I do not want to get into that. looks way too complicated compared to apache configs.

True I have never touched nginx so I could not judge it on there configs alone maybe there all suplied.

Anyways, There is a admin account on your linux system which is called ’ root ’ on newer linux systems this user is normally not able to login alone and you grant other users ’ sudo ’ power to use administrative rights. never the less the user root is still used to drive the system programs and logging.

The MariaDB is easy to setup and every time it is started it will check for insecure access. Hence you will always see

“[Warning] Access denied for user ‘root’@‘localhost’ (using password: NO)”

in your error.log That is why you need to share as much information about your system/logs when you want help here.

The user root in mariadb is the administrator and after you have secured your mariadb and created a account your pretty much done with that user.

setup mariadb and then create a user that can create a database for your nextcloud instance.
Here is how to setup MariaDB if newly installed and not used for anything other.

sudo apt install mariadb-server
sudo mysql_secure_installation

Answer all Yes with Y and set your root password
Now enter the database command line.

sudo mysql -u root -p 

this will open mysql with the user root asking for your password you made with mysql_secure_installation
This user is very powerfull and can destroy everything.
your command line should look like: mysql>

mysql command end with semi-colon ;
tell mysql to use the database mysql

use mysql;

now create a user for your nextcloud db so you do not have to enter the root account in your config.php

create user 'nc_dbuser'@'localhost' identified by 'YourP@s5w0rd';

The username for this account is nc_dbuser you can change it to what you want but for clearity this is the user to connect to the NextCloud DataBase

The localhost after @ tells mysql this user can only connect from the localhost which is your actual computer. no access from outside (WWW) allowed.
this is good for security.

Identified by obviously your own password here
Now we have a user we have to give it permissions what it may do.

grant all privileges on nextcloud.* to 'nc_dbuser'@'localhost';

This one could be better but will set it up no problems as access from outside is not allowed anyways.
grant all means all sql commands allowed now nextcloud.* means only allow it in database nextcloud and the .* means all tables inside nextcoud database.
the last part to again abviously the user to grant it to.

now I don’t know everything but you can use Google too

flush privileges;
quit;

your mariadb is now setup with a database named nextcloud this database can be accessed with username nc_dbuser and password: YourP@s5w0rd

this all seems to be already working fine for you.

Apache or NGINX

here is my apache command for setting up

apt install apache2 libapache2-mod-php libapache2-mod-php7.4 python3-certbot-apache certbot ssl-cert openssl php7.4 php-memcache php-imagick imagemagick  php-apcu php-redis php7.4-{bcmath,bz2,curl,gd,gmp,imap,intl,json,mbstring,mysql,opcache,pspell,readline,soap,tidy,xml,xmlrpc,zip}
sudo mkdir -p /var/www/nextcloud
sudo chown www-data:www-data /var/www/nextcloud/
cd /var/www/
sudo wget -O nc.tar.bz2 https://download.nextcloud.com/server/releases/nextcloud-19.0.2.tar.bz2
sudo -u www-data tar xjfp nc.tar.bz2
sudo a2ensite default-ssl.conf
sudo certbot run --apache -d cloud.usee.ga,www.usee.ga,usee.ga
sudo systemctl restart apache2
<VirtualHost *:80>
	Redirect permanent / https://cloud.usee.ga/
	ServerName usee.ga
	DocumentRoot /var/www/nextcloud
        ServerAlias www.usee.ga cloud.usee.ga
</VirtualHost>

<IfModule mod_ssl.c>
	<VirtualHost *:443>
		DocumentRoot /var/www/nextcloud
		ServerName usee.ga
                ServerAlias www.usee.ga cloud.usee.ga

		ErrorLog ${APACHE_LOG_DIR}/error.log
		CustomLog ${APACHE_LOG_DIR}/access.log combined

		<FilesMatch "\.(cgi|shtml|phtml|php)$">
				SSLOptions +StdEnvVars
		</FilesMatch>

		<Directory /usr/lib/cgi-bin>
				SSLOptions +StdEnvVars
		</Directory>

		<Directory /var/www/nextcloud>
				Options +FollowSymlinks
				AllowOverride All
                                SetEnv HOME /var/www/nextcloud
                                SetEnv HTTP_HOME /var/www/nextcloud

			<IfModule mod_dav.c>
			  Dav off
			</IfModule>
		</Directory>

                <IfModule mod_headers.c>
                          Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains"
                </IfModule>
            Include /etc/letsencrypt/options-ssl-apache.conf
            SSLCertificateFile /etc/letsencrypt/live/cloud.usee.ga/fullchain.pem
            SSLCertificateKeyFile /etc/letsencrypt/live/cloud.usee.ga/privkey.pem
</VirtualHost>
</IfModule>

Above is Apache site config
your NGINX may be pointing to /var/www/html/ or /var/www as webserver home I don’t know how you installed Nextcloud. some script or manually.
Maybe there are some missing modules please supply more info. no need to share sensitive information.

root user has nothing to do with nextcloud.

nc_dbuser is only to connect to your database. it’s login is stored in nextcloud/config/config.php

when browsing to your installation IP/DOMAIN you will create a new user for your nextcloud which will be the first user and will have admin rights for your nextcloud instance.

I hope this is of any help understanding users

Thank you for that thorough rundown! It helps confirm that my setup is looking okay so far.

When I finally got the NextCloud initial webpage to show up the other day for configuration. It asked me for a user name and I think that’s where I messed up.

Having tried configuration from command line for so long I gave it “root” as the “user” and my admin as the “admin user”. If that was not correct, is there any way to fix it?

Wait… no. My notes indicate that MySQL / NextCloud didn’t let me use root as the user.

Okay, back to the logs I go.

Thanks again for the information… and that that error is normal.

Error is normal as long as it’s not duplicated

Things you can try

Create a file CAN_INSTALL in your nextcloud/config/ go-to your cloud domain and see if you can continue installation.

sudo -u www-data touch /var/www/nextcloud/config/CAN_INSTALL

If not delete the file no harm done.

sudo rm /var/www/nextcloud/config/CAN_INSTALL

You can retry with a new database and a fresh extraction of the nextcloud.zip

Or drop the existing database en recreate .

To drop a database

sudo mysql -u root -u

drop database nextcloud;

create database nextcloud;

quit;

As the user already exists no need to create it again.

NEVER GIVE UP.

Thanks for sticking with me on this.

That error was duplicated… saw it in triplicate.

I was able to create the CAN_INSTALL file, but was not able to continue installation.

I quickly took your advice and stopped nginx, then mv’d the existing nextcloud directory to /nextcloud.old

I did a fresh extraction of nextcloud and set permissions for it.

I then dropped the old nextcloud database and created a new one.

I was able to get back to the setup page for NextCloud… but… now I’ve got new problems.

“MySQL username and/or password not valid You need to enter details of an existing account.” error when clicking the Finish setup button. I know that the username and password work, as I can use them to log in from the command line (via mysql - not linux).

Also of note. I didn’t create any new users in mysql… but I have my root and my “UserAdmin” and “NextCloudUser” at “localhost”… plus TWO EACH “oc_UserAdmin1” and “oc_UserAdmin2” accounts (one each at hosts “%” and “localhost”).

three times at the same time right here is my sql log for reference

2020-08-31 23:59:28 139822234860672 [Note] Using unique option prefix 'myisam-recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: The InnoDB memory heap is disabled
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Using Linux native AIO
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Using SSE crc32 instructions
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Completed initialization of buffer pool
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Highest supported file format is Barracuda.
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: 128 rollback segment(s) are active.
2020-08-31 23:59:28 139822234860672 [Note] InnoDB: Waiting for purge to start
2020-08-31 23:59:28 139822234860672 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.46-86.2 started; log sequence number 62506039215
2020-08-31 23:59:28 139822234860672 [Note] Plugin 'FEEDBACK' is disabled.
2020-08-31 23:59:28 139821565605632 [Note] InnoDB: Dumping buffer pool(s) not yet started
2020-08-31 23:59:28 139822234860672 [Note] Server socket created on IP: '0.0.0.0'.
2020-08-31 23:59:29 139822234860672 [Note] Reading of all Master_info entries succeeded
2020-08-31 23:59:29 139822234860672 [Note] Added new Master_info '' to hash table
2020-08-31 23:59:29 139822234860672 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.1.44-MariaDB-0ubuntu0.18.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Ubuntu 18.04
2020-08-31 23:59:29 139822234351360 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
2020-08-31 23:59:29 139822234351360 [Warning]  Access denied for user 'root'@'localhost' (using password: NO)
2020-08-31 23:59:29 139822234351360 [Warning] Access denied for user 'root'@'localhost' (using password: NO)

sorry forgot flush privileges;

sudo mysql -u root -p -e "flush privileges;"

Okay, sorry about the silence the past few days - had to deal with real life family stuff… so now back to the NextCloud.

After a bit of thought, and seeing that the NextCloud Setup/Configuration page appeared to be trying to create a new user with every attempt… I realized how to position my “Users” and passwords that NextCloud was asking for.

I gave it a brand shiny new NextCloud Database Administrator User name and passcode for the “Admin Account”.
I then gave it the “User Name” and passcode that I chose earlier when I setup MariaDB from the command line (while following the installation instructions) for the “Database User”.

… But, I still can’t get past the Initial Setup/Configuration page for NextCloud. Now it keeps giving me a “Can’t create or write into the data directory opt/nextcloud/data” Error message.

At least I’m making progress.

The nextcloud/data/nextcloud.log gives me the following three messages:
“Could not detect any host in http:///data/htaccesstest.txt”
“mkdir(): No such file or directory at /var/www/html/nextcloud/lib/private/Setup.php#312”
“Could not find resource js/setup.js to load”

I’ve checked the php.ini file for “open_basedir = none”. It wasn’t there, I added it. It made no difference.
I’ve checked my mySQL nextcloud database oc_storages table for correctly pointing at /opt/nextcloud/data
/opt/nextcloud and /opt/nextcloud/data belong to www-data user and group with 755 permissions (777 permissions made no difference… and 755 permissions mirror the default NextCloud install).

Any suggestions where to look next?

Since this now seems to be a different error / issue, I think I will stop this thread here, and post the previous post as another thread.