Need help to restore a Magento Website into new server.
I already restore the files to new server and tried to restore the MySQL via phpMyAdmin. But every time I try to import the MySQL, I am getting the following error:
SQL query:
Warning : USING UNIQUE OPTION prefix pass instead of PASSWORD IS deprecated AND will be removed IN a future release.Please USE the FULL name instead.-- MySQL dump 10.13 Distrib 5.5.42, for Linux (x86_64)
--
-- Host: localhost Database: XXXXXX
-- ------------------------------------------------------
-- Server version 5.5.42-cll
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Warning: Using unique option prefix pass instead of password is deprecated and w' at line 1
AT First Check your Server As following script:
extension_check(array(
'curl',
'dom',
'gd',
'hash',
'iconv',
'mcrypt',
'pcre',
'pdo',
'pdo_mysql',
'simplexml'
));
function extension_check($extensions) {
$fail = '';
$pass = '';
if(version_compare(phpversion(), '5.2.0', '<')) {
$fail .= '<li>You need<strong> PHP 5.2.0</strong> (or greater;<strong>Current Version:'.phpversion().')</strong></li>';
}
else {
$pass .='<li>You have<strong> PHP 5.2.0</strong> (or greater; <strong>Current Version:'.phpversion().')</strong></li>';
}
if(!ini_get('safe_mode')) {
$pass .='<li>Safe Mode is <strong>off</strong></li>';
preg_match('/[0-9]\.[0-9]+\.[0-9]+/', shell_exec('mysql -V'), $version);
if(version_compare($version[0], '4.1.20', '<')) {
$fail .= '<li>You need<strong> MySQL 4.1.20</strong> (or greater; <strong>Current Version:.'.$version[0].')</strong></li>';
}
else {
$pass .='<li>You have<strong> MySQL 4.1.20</strong> (or greater; <strong>Current Version:'.$version[0].')</strong></li>';
}
}
else { $fail .= '<li>Safe Mode is <strong>on</strong></li>'; }
foreach($extensions as $extension) {
if(!extension_loaded($extension)) {
$fail .= '<li> You are missing the <strong>'.$extension.'</strong> extension</li>';
}
else{ $pass .= '<li>You have the <strong>'.$extension.'</strong> extension</li>';
}
}
if($fail) {
echo '<p><strong>Your server does not meet the following requirements in order to install Magento.</strong>';
echo '<br>The following requirements failed, please contact your hosting provider in order to receive assistance with meeting the system requirements for Magento:';
echo '<ul>'.$fail.'</ul></p>';
echo 'The following requirements were successfully met:';
echo '<ul>'.$pass.'</ul>';
} else {
echo '<p><strong>Congratulations!</strong> Your server meets the requirements for Magento.</p>';
echo '<ul>'.$pass.'</ul>';
}
}
##Test What Exact Version PHP & MySQL
echo "<h2>Exact Version PHP & MySQL: </h2>";
printf("PHP version: %s\n", PHP_VERSION);
##### Without DB Access
ob_start();
phpinfo(INFO_MODULES);
$info = ob_get_contents();
ob_end_clean();
$info = stristr($info, 'Client API version');
preg_match('/[1-9].[0-9].[1-9][0-9]/', $info, $match);
$gd = $match[0];
echo '</br>MySQL: '.$gd.' <br />';
Related
Warning: mysql_connect(): (HY000/2002): Connection refused in
/home/vol14_1/byethost31.com/b31_16461744/htdocs/Mysql/con.php on line
7
Warning: mysql_select_db(): No such file or directory in
/home/vol14_1/byethost31.com/b31_16461744/htdocs/Mysql/con.php on line
8
Warning: mysql_select_db(): A link to the server could not be
established in
/home/vol14_1/byethost31.com/b31_16461744/htdocs/Mysql/con.php on line
8
I have the below code
<?php
$localhost="localhost";
$username=b31_16461744;
$pass=test123;
$dbname=b31_16461744_user;
$a= mysqli_connect($localhost,$user,$pass);
mysql_select_db($dbname);
if($a)
{
echo "connected..";
}
else
{
echo "not...!!";
}
?>
Sidenote: Assuming the credentials are correct, given to you by your web host.
There are several problems with this code (taken from a comment you left).
Firstly, three of your declarations are not quoted and are being treated as constants.
PHP error reporting would have thrown notices of undefined constants.
These are treated as constants:
$username=b31_16461744;
$pass=test123;
$dbname=b31_16461744_user;
You are also referencing the wrong variable for the username being $user which should be $username. Error reporting would have signabled an undefined variable notice.
Then you're mixing mysql_ with mysqli_ syntax. Those different MySQL APIs do NOT intermix. You must use the same one throughout your code.
Sidenote: The other question you posted Access denied for user 'test123'#'192.168.0.38' (using password: NO) you are using sql306.byethost31.com for the host. Make sure that is correct. I have no idea what settings that host wants you to use.
<?php
$localhost="localhost";
$username="b31_16461744";
$pass="test123";
$dbname="b31_16461744_user";
$a= mysqli_connect($localhost, $username, $pass);
mysqli_select_db($a, $dbname);
if($a)
{
echo "connected..";
}
else
{
echo "not...!!";
}
?>
or just use all four parameters:
<?php
$localhost="localhost";
$username="b31_16461744";
$pass="test123";
$dbname="b31_16461744_user";
$a= mysqli_connect($localhost, $username, $pass, $dbname);
if($a)
{
echo "connected..";
}
else
{
echo "not...!!" . mysqli_error($a);
}
?>
However, your else with the echo does not help you. Use mysqli_error() to get the real error.
I.e.: or die("Error " . mysqli_error($a));
Example from the manual
$link = mysqli_connect("myhost","myuser","mypassw","mydb")
or die("Error " . mysqli_error($link));
References:
http://php.net/manual/en/function.error-reporting.php
http://php.net/manual/en/mysqli.error.php
http://php.net/manual/en/function.mysqli-connect.php
http://php.net/manual/en/language.constants.php
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Displaying errors should only be done in staging, and never production
I Think Credentials are not correctly set. See Your connection statement.
For Reference :
While Working On Localhost, We write connection statement as :
$con=mysql_connect("localhost","root","");
$db1=mysql_select_db("DatabaseName",$con);
But, While working on server, we need to change the following credential.
Username and password values are must.
$con=mysql_connect("localhost","Username","password");
$db1=mysql_select_db("DatabaseName",$con);
I have created a website that has a MySQL database. I'm using phpmyadmin and xampp. Now I have a website to upload the files to (using Filezilla). How do I upload the MySQL database to the server and connect it to the website? I'm guessing there is already a tutorial somewhere but I couldn't find it.
If you have your database file ready to upload then in phpmyadmin there is an import option as shown in the image below:
In order to connect it to your website will depend on your server side language choice...
Example with PHP to connect your website to your database (using pdo):
<?php
$dsn = 'mysql:dbname=name_here;host=127.0.0.1';
$user = 'root'; //change to your username
$password = '******'; //change to your password
try {
$pdo = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
exit;
}
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
Once you have that at top of your PHP file you can connect. This one way to do it via PHP.
The following is the most basic and simplest code I ever wrote, what could be wrong with that code?
<?php
$con=mysqli_connect("localhost","root","myroot","mydb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "Connecting to server Localhost succeeded ! ";
}
// Add column
$sql="ALTER TABLE june2013 ADD time_interval (DECIMAL(5,2))";
if (mysqli_query($con,$sql))
{
echo "Column added successfully";
}
else
{
echo "Error creating database: " . mysqli_error($con);
}
mysqli_close($con);
?>
I get an error message that says:
Connecting to server Localhost succeeded !!! Error creating database: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(DECIMAL(5,2))' at line 1
Any idea why I'm getting this?
Could it just be that you are missing "COLUMN" from the statement?
$sql="ALTER TABLE june2013 ADD time_interval (DECIMAL(5,2))";
should be
$sql="ALTER TABLE june2013 ADD COLUMN time_interval DECIMAL(5,2)";
I'm trying to cope with MySQL's error MySQL server has gone away in a django env.
The quick workaround was to set the global wait_timeout MySQL variable to a huge value, but in the long run this would accumulate to many open connections.
I figured I'll get the wait_timeout variable and poll the server in smaller intervals. After implementing this I tried to test it but am failing to get the error.
I set global wait_timeout=15 and even set global interactive_timeout=15 but the connection refuses to disappear. I'm sure I'm polling the database in larger intervals than 15sec.
What could be the cause for not being able to recreate this error?
Run below dirty-and-quick script and test your django project or whatever. I think this is not an elegant approach, but it works well.
<?php
mysql_connect( "127.0.0.1", "id", "pw" ); // should be changed to yours
while(1)
{
$r = mysql_query( "SHOW PROCESSLIST" );
while( $d = mysql_fetch_row( $r ) )
{
if( $d[7] != "SHOW PROCESSLIST" )
{
mysql_query( "KILL ". $d[0] );
echo( $d[0]." was killed.\n" );
}
}
}
?>
And here is the result.
mysql> select * from foo;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 337
Current database: test
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 338
Current database: test
ERROR 2006 (HY000): MySQL server has gone away
mysql>
I've made a few modifications to #lqez code to be used with mysqli:
<?php
$mysql = new mysqli("127.0.0.1", "user", "password", "database"); //should be changed to yours
while (1) {
$r = $mysql->query("SHOW PROCESSLIST");
while ($d = $r->fetch_row()) {
if ($d[7] != "SHOW PROCESSLIST") {
$mysql->query("KILL " . $d[0]);
echo($d[0] . " was killed.\n");
}
}
}
?>
I'm getting the following error on my site when I upload it or submit a page:
mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
What in the world does this mean?
Since the error is being thrown by the call to mysql_real_escape_string() it rather implies that you didn't call mysql_connect() first and pass a valid db handle to mysql_real_escape_string (or the call to mysql_connect() failed).
In some circumstances, the mysql extension will attempt to connect automatically using the default settings in php.ini, failing over to my.cnf if these are not available - which obviously are not valid. Or it may be that the settings are valid but the mysqld is not running.
Have you got scripts which are connecting to the database successfully?
Do you have a username and password for the database?
Try:
check_running();
$user=''; // fill in your details
$password=''; // fill in your details
$hosts=array(
'localhost', '127.0.0.1', $_SERVER['HTTP_HOST'], $_SERVER['SERVER_ADDR']
);
foreach ($hosts as $addr) {
try_con($addr, $user, $password);
try_con($addr . ':3306', $user, $password);
}
function try_con($host, $user, $password)
{
$dbh=mysql_connect($host, $user, $password);
if ($dbh) {
print "Connected OK with $host, $user, $password<br />\n";
} else {
print "Failed with $host, $user, $password<br />\n";
}
}
function check_running()
{
// this assumes that you are using Apache on a Unix/Linux box
$chk=`ps -ef | grep httpd | grep -v grep`;
if ($chk) {
print "Checking for mysqld process: " . `ps -ef | grep mysqld | grep -v grep` . "<br />\n";
} else {
print "Cannot check mysqld process<br />\n";
}
}
Yes exactly, some servers pass the default connection parameters when using mysql functions before connection and throw off an error, some other servers work just fine wherever you place the code
it is always safer to just place mysql_real_escape_string() after establishing mysql_connect() connection