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"
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 keep on getting this message what could be the problem 1
This means that your username/password is not correct.
If you forgot your root password, you can recover it using the instruction in this link (I'm assuming from your screenshot that you are using Windows)
https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/resetting-permissions-windows.html
On Windows, use the following procedure to reset the password for the MySQL 'root'#'localhost' account. To change the password for a root account with a different host name part, modify the instructions to use that host name.
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.
If your server is not running as a service, you may need to use the Task Manager to force it to stop.
Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use.
MySQL 5.7.6 and later:
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Save the file. This example assumes that you name the file C:\mysql-init.txt.
Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\> cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"
C:\> mysqld --init-file=C:\\mysql-init.txt
If you installed MySQL to a different location, adjust the cd command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing the 'root'#'localhost' account password.
To have server output to appear in the console window rather than in a log file, add the --console option to the mysqld command.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option. For example:
C:\> mysqld
--defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 5.7\\my.ini"
--init-file=C:\\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
You should now be able to connect to the MySQL server as root using the new password. Stop the MySQL server and restart it normally. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.
If the ALTER USER statement fails to reset the password, try repeating the procedure using the following statements to modify the user table directly:
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
Follow the instruction and you will be fine.
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';
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