MySQL how to find host and user info? - mysql

how do I find out what my database hostname and user login is? I've tried localhost and root#localhost but no success.
Failed to connect to database host.domain.com:3306 user:root. Please
check the database settings you provided and verify that MySQL is up
and running.

Assuming that mysql is running and you have credentials that work, you can get all the host and user information from the mysql database once you are running mysql successfully - "select User,Host from mysql.user" for example.
But, it looks like your problem is that you can't log into mysql.
If you don't have a valid credentials to your own database, one has to wonder how you managed to lose them. That happens, however, and the way to reset those credentials is described in detail at http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html.

Related

Database named "Wordpress" present in SSH but missing in MySQL Workbench

I am trying to configure my Linux server to create a staging environment for my Wordpress Multisite. I am trying to access the wp_options table to be able to make changes, but I'm getting a garbled mess of dashes when I attempt to "SELECT * FROM WP_OPTIONS".
To counter this, I am attempting to use MySQL Workbench to see if it tidies up the mess. However, while I see the database entitled "wordpress" when I SSH into the server (I'm using Google Cloud Platform as my host), I do NOT see the database when I use MySQL Workbench!
I'm running sudo when activating mysql in SSH, and I'm logging in as "root" when using MySql workbench, so the permissions should be the same.
Below is the comparison between the SSH and what I'm seeing after running a "SHOW DATABASES;" command between them:
How can I get the wordpress database to show up in MySQL Workbench???
Edit 1: I have ruled out that this is a permissions issue- using SELECT_CURRENTUSER(); I see that I am logged in as the exact same account in both (root#%), so despite having the EXACT same permissions I am getting different tables showing.
You should consider logging in through your root session and then updating your permissions to view the database as the correct user, from whatever server you'd like.
GRANT ALL PRIVILEGES ON <Database Name>.* TO '<Username>'#'%';

phpMyAdmin login information?

I am trying to view my database by using phpMyAdmin. I was wondering where I can find out the server name that should be inputted into the form? I believe my username and password should be what I use when I access MySQL from the command line. Thanks
UPDATE: Tried local host and 127.0.0.1 and got this error:
If you still can connect using the CLI mysql on the server console you can use the command below to see which account and host name you are able to use:
select * from mysql.user;
Eventually you can define a new sysadmin with password to be used with php as described at
https://corpocrat.com/2008/09/28/how-to-create-new-user-for-phpmyadmin-login/

Process order for --skip-grant-tables mysqld

I have a question about a scenario i currently have. generally the process should work but i can't seem to login successfully afterwards. either getting an incorrect username/password combination or an "unable to select Database" error when logging in with any credentials.
to skip forward a bit i have shutdown the mysql server on the machine and restarted it with the command
/etc/init.d/mysqld --skip-grant-tables
then logged in with mysql -u root -p
obviously this lets me in straight away as it skips the permissions check.
My goal is to change the password on a for a user on a table.
Currently there are three databases on the server we will call them as follows.
INFORMATION_SCHEMA
mysql
gnb
There is a table in gnb called users which has a username an password field. it has a single entry called admin under username which i want to change the password for as that is where the web server pulls the data from.
i have successfully changed the password for this particular user with the command
UPDATE users SET Password=PASSWORD('MyNewPass') WHERE username='admin';
FLUSH PRIVILEGES;
And 1 row is affected and i can visibly see the password hash change. also flushing privileges.
here's where i run into my problem....
once i have reset the password and restarted the mysql server in a normal mode i navigate back to the web server login and attempt to log in with the details that i now have.
i'm met with a "unable to select database" error message.
i'm not sure if i have to do something prior to restarting the database? or do i also have to restart the apache web server? i have tried a mirage of different combinations of things but just can't seem to get it working. if i attempt to log in whilst still in --skip-grant-tables mode then i just get an invalid login attempt.
thanks in advance/
I'm stumped....
I think you may have a misunderstanding about how the MySQL authentication system works.
When an application (e.g. a PHP script) connects to MySQL, the user/password checks against the mysql.users table. It does not check any other table in another database, even if that database (gnb) is the database that contains your application's data.
The fact that you have a table called "users" in your gnb database has no bearing on the MySQL authentication system. Of course you can put any data you want into that table, but it won't be used by MySQL authentication.
You can change passwords with the SET PASSWORD command, or you can UPDATE the mysql.users table directly and then FLUSH PRIVILEGES.
for the future.
second table was storing passwords in MD5.
update the row without using any password commands. simply a row update and update it with the MD5 hash of the password i was wishing to use.
web server then recognized the MD5 string as being the correct password and i was able to gain access.

Connect to MySql using IP address

I have written some code and am currently running it using loachost however am trying to set it up so that I can run the app from other computers, I am using MySql and after searching online I found that if I replace "localhost" with my IP address (found from google) for the host name on MySql I will be able to connect from other machines, I tried this and got an error saying that I cannot connect to the server and listed some checks:
Check that MySql is running on the servr - how do I check this?
Check that MySql is running on port 3306 - I changed this to 3307 when making the database however, I tried both and got the same errors.
Check if root has rights to the IP address from your address - I am running this from the same computer and it has worked fine with localhost so I dont know why it wouldnt but how would I check this?
Make sure you are providing password - I did when I tried to connect to the database and got this error.
Could someone please help me, I have been searching for hours and cant find how to fix this.
You need to grant access to the account root#%.
root#localhost and root#% are two different accounts. When you're using localhost as the hostname, and specify user name root, you use root#localhost.
When connecting using an external IP, you need to grant database access for root#%.

MySQL workbench - Can't connect to a specific database

I'm facing a strange issue here and it seems impossible to me to connect to my MySQL database.
I have used the workbench few times ago, but it was an older version. The problem with the new one (6CE) is that I can't connect directly to a database - it only allows me to create a connection to the server as a root user and I don't remember this password.
Is there a way to make a connection directly to the dataase itself as in the previous versions, or now only the root is an option. If yes I will have to reset my password.
Make sure that your credentials are still valid, and has proper privileges. If you can log into your mysql-server from terminal (with root account or the user you are trying with), then run "SHOW GRANTS" and see the privileges;
To connect to mysql database you need to have your user account's hostname specific to your IP or wildcard (%).
Similarly you can create a new mysql user with the following command from your server, and then try with this new user.
GRANT ALL ON <db>.* TO 'user'#'<ip or %>' IDENTIFIED BY '<password>' ;
FLUSH PRIVILEGES;
Be careful with the user created above. It will have ALL privilege with the specific database. And using % is actually a bad idea, so user you home machines IP (from where you are trying to connect with Workbench)