Recently, I've started using openshift & also deployed an application using PHP & MySQL. Yesterday, out of curiosity, I've removed the password for phpMyAdmin and guess what, now I'm unable to log in to both phpMyAdmin & mysql database.
I've tried both the passwords (the default one & the empty password) and uninstalled & re-installed the PHPmyAdmin catridge & also, force restarted the app several times but nothing worked. Now, I've no idea what happened. Any help is appreciated.
Hopefully this will help.
I assume what you did was go into phpmyadmin and click on 'users' then 'edit privileges' for one of the users, select 'no password' and hit save right? If so, then I think the following steps should help.
1.) ssh into your gear (you can use the rhc ssh command)
2.) run the mysql command
3.) You should get an error like this ERROR 1045 (28000): Access denied for user 'adminslULJTS'#'127.10.126.130' (using password: YES)
4.) Now, type in the command mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST -P $OPENSHIFT_MYSQL_DB_PORT -p
5.) When it asks for a password, just hit enter
6.) You should now be logged into the mysql shell
Now you need to reset your password to what openshift thinks it is.
1.) create another ssh session into your gear in another terminal, leaving the old one open
2.) run the command env | grep MYSQL
3.) this will give you the following information that you will need to reset your password:
OPENSHIFT_MYSQL_DB_HOST=127.10.126.130
OPENSHIFT_MYSQL_DB_PASSWORD=Il8-rVLIKSrx
OPENSHIFT_MYSQL_DB_USERNAME=adminslULJTS
Given the above information, go back to your ssh session that had the mysql connection open, and enter the following command:
set password for 'adminslULJTS'#'127.10.126.130' = PASSWORD('Il8-rVLIKSrx');
But you will need to replace the username, host, and password with the ones you got from the above step.
You should now be able to log into phpmyadmin with your old username & password that you can either view using the env | grep MSYQL command, or view in the web console for your application at openshift.com
It also might be worth reviewing this KB article: https://www.openshift.com/kb/kb-e1085-possible-complications-when-changing-your-database-credentials
Related
I installed Apache2 and MySQL client/server and PHP8.1.2 manually. Ubuntu 22.04 successfully connected to the database from the terminal, changed the root password, exit.
Next, I tried to install the web control panel.
I first downloaded Froxlor from git https://github.com/Froxlor/Froxlor
to the /var/www/froxlor
master branch folder. Then I installed all the dependencies from the list, but this was not enough. The PHP application code gave out unsatisfied dependencies.
Here https://deb.froxlor.org/debian/pool/main/f/froxlor/ found the DEB package and installed it in the same folder through the terminal, satisfying all the dependencies with this - the code worked.
Then I started the installation. through the browser. By going to /index.php I am offered no options to go to ./install/, where I fill in all the relevant fields (maybe not correctly?) in the second window of the page and after clicking "submit" I get an error:
Checking MySQL-root access... SQLSTATE[HY000] [1698] Access denied for user 'root'#'localhost'
There seems to be a problem with the database-connection. Cannot continue. Please go back and check your credentials.
such an error crashes in the terminal if you connect to the database without "sudo", here I was confused. I have researched /install/lib/class.FroxlorInstall.php on the subject of at least some zatseki what should I do and still tried to add "sudo" in the file /tests/bootstrap.php in line 50
exec("sudo mysql -u root -p" . $rpwd . " froxlor010 " . dirname(DIR) . "/install/froxlor.sql");
but it didn't lead to anything. Maybe there is some similar experience, please tell me. Thx
P.S. I also tried to install via froxlor.phar, but my installation hung up at the moment of connecting to the database, perhaps the script was waiting for the password to be entered, but this was not reflected.
Oh, I solve it by my self.
It need to create file ../froxlor/lib/userdata.inc.php by this example:
<?php
// automatically generated userdata.inc.php for Froxlor
$sql['host']='localhost';
$sql['user']='froxlor012';
$sql['password']='PASS';
$sql['db']='froxlor';
$sql['ssl']['caFile']='';
$sql['ssl']['verifyServerCertificate']='0';
$sql_root[0]['caption']='Default';
$sql_root[0]['host']='localhost';
$sql_root[0]['user']='frox';
$sql_root[0]['password']='PASS';
$sql_root[0]['ssl']['caFile']='';
$sql_root[0]['ssl']['verifyServerCertificate']='0';
// enable debugging to browser in case of SQL errors
$sql['debug'] = false;
?>
also you need to create 'froxlor','froxlor012' and 'frox' users (step forward: dont foget to change the PASS's, it may not be empty, and to GRANT users to 'froxlor' database) and empty 'froxlor' database ( step forward: if you have no back up of DB you can take back up of this example https://www.dropbox.com/s/6guus4uxc9v2agf/froxlorbackup.sql?dl=0 ) in MySQL, then run in terminal:
sudo php /var/www/froxlor/install/scripts/config-services.php --froxlor-dir=/var/www/froxlor/ --create
sudo mysql -h localhost -u 'root' froxlor < /home/administrator/froxlorbackup.sql
so we have manualy install froxlor without any mistakes of installer. You will find user name froxlor with PASS in DB backup.
I am a beginner with PHP and with mySQL. I am trying to do something very simple. I have read through many solutions on Stack Overflow and I have tried many different things but nothing has worked. I am simply trying to connect to MySQL with PHP. I have a MySQL Active instance running. I am using a Mac. I can successfully connect to it using the following commands from the terminal:
mysql -u root -p
This then prompts me to enter my password:
Enter password:
I then type in my password. It is a throwaway password. It is "Snow1234". It then works successfully. It shows
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
....
mysql>
I can then enter commands in my terminal which all work correctly.
I am trying to do the same thing with php (keep in mind that I am a beginner and I have never used it before).
I have a file called form.php.
form.php:
<?php
mysql_connect('localhost','root','Snow1234');
?>
I save the file. Then, I upload the file to a URL that I own using Filezilla. Then, I visit the URL in my browser (Google Chrome):
http://www.myWebsite.com/form.php
However, it says on the website:
ERROR: Could not connect. Access denied for user 'root'#'localhost'
(using password: YES)
How do I fix this?
I see you have uploaded form.php to a server. You have to check The password and username to the database hosted at your server.
ERROR: Could not connect. Access denied for user 'root'#'localhost'
(using password: YES)
This error is simply wrong password or username to connect to the database. You could connect to the database on your terminal, probably because you are connecting to your local database(your computer). But your form.php is now on the server attempting to connect to the database there (on the server).
You will need to access the CPANEL of your server to help you create the database etc.
Not sure if there is a need for you to have this on the server(ie accessible from anywhere on the internet). Otherwise, consider installingXampp to your computer. Then,
Have the form.php stored in a folder {myproject} C://XAMPP/htdocs (depending on where you install it).
Create a database through localhost/phpmyadmin
Connect to the DB at your PHP side, the same way as you do now.
But note, by default the username is root and password is empty.
You can now access your form via http://localhost/myproject/form.php
Final Note: this is only accessible on your computer.
Please refer this link will help you.
1.Open a Connection to MySQL
2.MySQLi Procedural
3.PDO Connection
[https://www.w3schools.com/php/php_mysql_connect.asp]
I'm new to Ubuntu. I tried to run a .php file and connect it to a database. Everything is on-set. I already imported the database in phpMyAdmin but every time I access my database,it returns an error
This page isn’t working localhost is currently unable to handle this
request. HTTP ERROR 500
Turns out, it seems like my database isn't running at all. In Windows I just open the XAMPP and click Apache and MySQL buttons. While in Ubuntu,
I have no idea on how to start or run MySQL and Apache. I already tried running commands on the terminal but it won't help. Someone has already installed it on this computer, I just don't how to run it and what web-server platform is this running.
How do I do it and how would I know that my database is running and accessible?
Try to connect your database and access database via command line.
mysql -u [username] -p
you can replace [username] with your real username of mysql like root
it will prompt for password so you are type yours like root
prompt will say
mysql>
now you need to list all databases to see is database exists or not
show databases;
it will list down all databases. you may verify is your exists or not
then you can select database by
use databasename;
and then run
show tables;
it will show all tables.
so you can verify that mysql working, database exists and tables are there or not.
Use this command it will start the database is you have it
systemctl mysql start
This should do the trick you need to have mysql database or maria db installed
Check by running this command in terminal after the first one
mysql
And you can also add argument like host and login
mysql -h (your host default is localhost) -u (user default is root) -p (password default is none)
Check your files access level
sudo chmod -R 777 "location of your file"
I would like to host a database on my raspberry pi to which I can access from any device. I would like to access the contents of the database using python.
What I've done so far:
I installed the necessary mysql packages, including apache 2.
I created my first database which I named test.
I wrote a simple php
script that connects and displays all the contents of my simple
database. The script is located on the raspberry pi at /var/www/html
and is executed when I enter the following from my laptop
(192.168.3.14/select.php)
Now my goal is to be able to connect to the database using python from my laptop. But I seem to have an error connecting to it, this is what I wrote to connect to it.
db = MySQLdb.connect("192.168.3.14","root","12345","test" )
Any help or direction is appreciated.
on the terminal of your raspi use the following command:
mysql -u -p -h --port
where you switch out your hostname with your ip address. since currently you can only connect via local host
at first step is check you haven't firewall rules on raspberry or in your lattop
after you can try this command on mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%';
and remember to apply new privileges
FLUSH PRIVILEGES;
for more detail you can see
https://dev.mysql.com/doc/refman/5.7/en/grant.html
is similar for mariadb ecc...
The reason why you are not able to connect to the database from outside of localhost is that the remote access for the root user is prohibited by default, i.e. you can only access the database with the root user from localhost. You can, however, change this by tweaking root's privileges. Please take a look here to find out how the user privileges need to be change to make this work.
Setting. I'm running Ubuntu 15.04 on a custom machine with an existing PHP / Apache / Sqlite setup. I recently installed MySql to fiddle around with Laravel a bit. It was working perfectly until I wasn't paying attention and did something incredibly stupid. I intended to export all of the user's privileges to a new database, was in a hurry, and instead clicked the button to dump all users. So, yeah. Complete dumped every user in MySql, including root. Obviously I was unable to log back in with PhpMyAdmin, because no root user. Since this was just a testing install I went ahead and purged MySql and re-installed, thinking it would just go through the install process again. NOPE. I've uninstalled / reinstalled using the terminal, synatpic, and Ubuntu Software Center. In each case the install of MySql client server just breezes through without even asking for a root user. I can't even check status to see if the server is running without getting an unauthorized error. I would really like to get this fixed, but without uninstalling apache2 and php. Any help would be greatly appreciated.
After yet another purge / install cycle I have mysql mostly working again. I can log in as root from the command line, and I am able to log in via PhpMyAdmin, for the most part. Unfortunately, while I seem to still have all of the necessary PhpMyAdmin functionality the page itself throws several iterations of the following error:
Connection for controluser as defined in your configuration failed.
I've researched this error and none of the conditions that are said to cause it exist in my system.
First try this.
mysql -u root -p password
if first method does not work then use following method to reset your MySQL password.
Check your version of the MySQL database.
apt-cache policy mysql-server
Start configuration setting of the MySQL database.
sudo dpkg-reconfigure mysql-server-** . **
"replace ** . ** with your MySQL database version"
It will open a configuration prompt where you will can change password.
If both of the above methods fails then use this method as last resort.
Stop your MySQL database server
sudo /etc/init.d/mysql stop
Start demon process without grant table.
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
Start MySQL and flush the privilige.
mysql -u root
FLUSH PRIVILEGES;
Now set the password for the root user.
USE mysql
UPDATE user SET Password = PASSWORD('newpwd')
WHERE Host = 'localhost' AND User = 'root';