Current situation is as follows:
I have succesfully installed OpenProject on Ubuntu 14.04 server using the guide from the official website (https://www.openproject.org/open-source/download/packaged-installation-guide/). When configuring for the first time I let the configuration manager install MySQL and create the appropriate database(s).
Now I'm trying to migrate and for this to happen, I need outside access to the information_schema (schema) and database. This is supposedly done using the openproject user but I cannot seem to be able to login using this user on the commandline.
Just to be sure, I just statement below:
mysql -u openproject -D openproject -p
Then I entered the right password and press enter. It gets the default ERROR 1045.
I am however able to login using root user and debian-sys-maint user which was created on the initial install step. The password I used for these accounts were found in the file under "/etc/openproject/installer.dat". I am absolutely positive I use the correct password, for the application runs fine under said user.
Is there a setting in mysql that I am missing that would block users from making connection using the commandline utility?
Figured it out. In MySQL the host 127.0.0.1 and localhost are essentially different. User OpenProject by default gets assigned to host 127.0.0.1, so naturally connecting openproject#localhost did not work, though root account has different user profiles (4 to be exact) allowing it to connect to both localhost and 127.0.0.1 .
TLDR version:
Use the statement as follows:
mysql -u openproject -h 127.0.0.1 -p
Should do the trick.
Related
I set up a new computer running macOS 10.14.5 and Docker Desktop community 2.0.0.3 (31259) and I noticed that my MySQL container wasn't being created properly. This is the command that I had run on my previous computer:
docker run --name virtual-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mypassword -d mysql:5.7.22
That worked: it would properly set the root password. But on the new computer, when I run that command, the root password is NOT set. I can log in as the root user, but only if I leave the password blank. Only the root user can create a database.
But more curiously, I can specify ANYTHING as the user, e.g. asdf and successfully log in (!!!). When I log in as a non-existent user, I can only view the information_schema and I cannot create a database, however -- I get an error: Access denied for user ''#'localhost' to database 'asdf' -- which suggests that perhaps my client isn't sending the login credentials correctly (I am using Sequel Pro 1.1.2 as my MySQL client).
Can someone explain this strange behavior?
After some helpful nudging, I figured out where this was going off the rails.
First problem: one of the apps I installed had installed an instance of MySQL onto the host OS. I didn't notice it because I had done which mysql from an open Terminal window that didn't have its PATH updated.
Second problem: mysqld kept running a process that bound to port 3306.
I didn't notice this until running lsof -Pnl +M -i4 | grep 'LISTEN'lsof -Pnl +M -i4 | grep 'LISTEN' revealed it. I had my suspicions when I could bring up new dockerized instances bound to other ports.
So the solution was to THOROUGHLY delete mysql (and mysqld), then REBOOT to shake any dangling connections. Once I had done that, my dockerized versions ran fine.
I am using "mysql -u root -p" command to start mysql but I am getting error as:
Access denied for user 'root'#localhost''
I always have to use sudo to to launch it. Other applications start normally. How do I get around it? I am doing jdbc connection (java). Mysql doesn't give access to database in java. I think requiring sudo command is the problem.
System:
Ubuntu 18.04 LTS dual booted with Windows 10.
I always have to use sudo to to launch it
No. You need to use sudo to get the client to authenticate against the server.
The reason for this is that recent versions of MySQL (and MariaDB, PerconaDB) use SO_PEERCRED to very that the username asserted in the connection string (root) is the same user as started the client (this makes use of a password somewhat redundant).
Since SO_PERRCRED only works on filesystem sockets (AF_UNIX) you may be able to bypass the constraint by connecting via a network socket, e.g.
mysql -h 127.0.0.1 -u root -p
But do be aware that MySQL typically has separate user records for connections via network (host != 'localhost') and filesystem (host='localhost') sockets.
But as per the question #Ciarambola flagged, 'root' is a special case and should not be used for routine access - you should create a new user.
Mysql doesn't give access to database in java
You should never use an admin account as the embedded credentials in an application. If you make that account with the same name as your user you won't need to use sudo when you connect to 'localhost'.
I have recently installed MySQL 5.7.16 on an iMac running El Capitan. I had a few minor hiccups initially because I forgot the root password but that has now been reset and I can now log into MySQL as root user using:
$ mysql -u root -p
However, when I try to connect to MySQL server as root using SequelPro, I get the message:
Unable to connect via the socket, or the request timed out.
Double-check that the socket path is correct and that you have the necessary privileges, and that the server is running.
MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.
When I look in /tmp folder, I was expecting to find mysql.sock but, instead, there is a file called mysql.sock.lock. Could this be causing the problem? I can't find where that .lock file has come from and I'm not sure what to do about it. Any help would be appreciated.
I'm not entirely sure what happened to cause the root password to expire but something had thrown a spanner in the works. Anyway, the solution for me was to log into MySQL from the Terminal using:
$ mysql -u root -p
...and then alter the root user's password using:
> ALTER USER 'root'#'localhost' IDENTIFIED BY 'NewPass';
That seemed to do the trick. I was then able to log in to MySQL using Sequel Pro with no problems.
Instead of using a socket connection, you could try connecting via Sequel Pro's standard connection using 127.0.0.1 as the host.
Thus spake the 5.7 docs:
The installation process creates only a single root account, 'root'#'localhost', automatically generates a random password for this account, and marks the password expired. The MySQL administrator must connect as root using the random password and assign a new password. (The server writes the random password to the error log.)
So, connect from terminal and change the root password.
Either your first password may not have been saved OR it just truly never persisted.
For me it was the sudo /usr/local/bin/mysql_secure_installation that may not have ever persisted the password correctly. Since your first password never changed, there is no password or ,like your error said, "expired" to nothing.
Run or rerun the code above, don't type anything for the password field and follow the steps, from the preloaded setup program.
I have a remote mysql instance (not on the local machine, but on the same subnet as my testing platform) that I'm using for testing. So that I can mimic the real database in the application, I've modified /etc/hosts with the following two entries:
192.168.1.249 macduff
192.168.1.249 dc2-mysql-01.kattare.com
Everything works fine when I attempt to access the database remotely using
mysql -h 192.168.1.249 -u myusername -pThePassword
and
mysql -h macduff -u myusername -pThePassword
However, when I use
mysql -h dc2-mysql-01.kattare.com -u myusername -pThePassword
The mysql monitor seems to connect, but it then hangs. It prints the usual password warning but doesn't print the Welcome to the MySQL monitor message, for example. The monitor also doesn't respond to any input. I'm assuming that I've got the user set up properly, given that I can access the instance using the IP address and the single-word alias. I have a single % as the host name associated with the user. If it matters, I'm using a Homebrew install of mysql 5.7.12 on a mac running El Capitan on both the local and remote machines.
MORE INFO:
Just tried creating a user with the dc2... address listed explicitly as a host, but that didn't help (which seems to imply that this isn't a CREATE USER or GRANT issue). I let mysql run for a while, and eventually something timed out and I got a
ERROR 2003 (HY000): Can't connect to MySQL server on
'dc2-mysql-01.kattare.com' (60)
Which implies a DNS problem, but the dc2... address works fine in the browser, so it appears to be something mysql related. DNS in mysql is enabled (it recognizes the single-word alias macduff without difficulty).
Any idea what's going on?
I am trying to install drupal on remote mysql server. I have created the user in mysql and granted the the privileges.
I am able to connect through command line from my web server like this "mysql -u xxxx -h 10.xxx.yy.zz3 -p".
But when I tried to install drupal I get "SQLSTATE[28000] [1045] Access denied for user 'xxxx'#'localhost'". I have given the privileges for "xxxx"#"10.xxx.yy.zz3" but drupal appends localhost instead of IP to user name. I have changed settings.php to mysql server IP.
What am I missing?
Instead of editing the settings.php file, try the following:
The third screen during installation (Database configuration) let you set up the database on a remote MySQL server. To do so, expand Advanced options and enter the database host.
I cannot guarantee that this will work, but this is how I set up Drupal to use a remote MySQL server, and I have never had this problem. Btw, I always use the canonical domain name (e.g. mysql.example.org) and not the IP-address.