MySQL

MySQL Master-Slave replication between CentOS 6 cPanel server

Here I am going to illustrate how to replicate MySQL database between Master and Slave Servers. Requirements: Two cPanel preinstalled servers with same versions of MySQL database server. eg : Master server –  198.228.227.1 Slave server – 198.228.227.2 Master server configuration Default location of MySQL server configuration file will be located at /etc/my.cnf Add the following changes to the configuration…
Read more

Read BLOB to string in PHP (Symfony2)

I have a MYSQL DB where I store encrypted credentials for an IMAP account. The field for the password is a BLOB as recommended. $encrypter = new TripleDES(CRYPT_DES_MODE_ECB); $encrypter->setKey($this->container->getParameter(‘secure_token’)); $encrytped_pw = $encrypter->encrypt(“MYPASSWORD”); $mailbox->setUrl(‘{outlook.office365.com:993/imap/ssl}’); $mailbox->setUsername(‘user@domain.tld’); $mailbox->setPassword(base64_decode($encrytped_pw)); $em->persist($mailbox); $em->flush(); Unfortunately I am not able to decrypt this field with this: $mailboxPw = $this->getUser()->getMailbox()->getPassword(); $decrypter = new TripleDES(CRYPT_DES_MODE_ECB); $decrypter->setKey($this->container->getParameter(‘secure_token’)); $decrytped_pw = $decrypter->decrypt(base64_encode($mailboxPw)); as…
Read more

Warning: mysql_query(): Access denied for user ‘admin’@’localhost’ (using password: NO)

It seems as though my PHP is trying to log in to the MySQL database with a username I am not supplying. The error I am getting is: Warning: mysql_query(): Access denied for user ‘radiocaf’@’localhost’ (using password: NO) in /home/radiocaf/public_html/layout.php on line 16 Warning: mysql_query(): A link to the server could not be established in /home/radiocaf/public_html/layout.php on line 16 I…
Read more

How to store images and serve on website

I need a script for a user to upload 5 images for their product on a website. All other users have the ability to view the images only. I think the best way is for the account user to create a folder and then upload required images into it. I dont think I need to register the images into a…
Read more

PHP reuseable delete row with ajax

My code repeat for everytable. The ajax function and file delete.php repeat everytime I want to delete. Example I have 100 table in mysql I have to make 100 delete.php => can I use 1 delete.php for all, same with ajax function as well Thank you PHP code, echo”<td><a href=’#’ onclick=’doConfirm(“.$id.”)’>Delete</a></td>”; Ajax code function doConfirm(id) { var xhttp; var ok…
Read more

Mysql how two update parent child table in one sql and parent use child’s update column

I have two table. parent and child. parent has column arrange_quantity, child has a column arrange_quantity too. parent.arrange_quantity = SUM(child.arrange_quantity). I want update the two arrange_quantity in one sql. but subquery seems always get old child.arrange_quantity value, how can I get new child.arrange_quanity. My sql now below : UPDATE child child LEFT JOIN parent parent ON child.`arrange_id`=parent.`id` SET child.`arrange_quantity`=11, parent.`arrange_quantity`=(…
Read more

"System lock" status of "CHECK TABLE `mytable`"

Got partitioned innodb table mytable. Got problems while trying to execute “CHECK TABLE mytable“. Process hangs with “System lock” status. mytable is partitioned: /*!50100 PARTITION BY RANGE (UNIX_TIMESTAMP(dt)) (PARTITION p20150702 VALUES LESS THAN (1435870799) ENGINE = InnoDB, PARTITION p2015w27 VALUES LESS THAN (1437944399) ENGINE = InnoDB, PARTITION p2015w28 VALUES LESS THAN (1438376399) ENGINE = InnoDB, PARTITION p2015m08_1 VALUES LESS THAN…
Read more

Import database MySQL File-Per-Table Tablespaces to Same Server

Is necessary copy a database within a single server. Was chosen way to “File-Per-Table Tablespaces to Another Server” as it is the fastest for large databases. The official documentation states that the database name must be the same on the source server and the destination server. What if the source server and the destination server – this is one and…
Read more

Showing mysql rows content in html table using php

im new here and i have a question, i looked for the solution everywhere and i still cant manage to solve this. I want to show the results of the SELECT statement (in php) in a table (html) using JS. Here is the code of these 3 files: HTML file <html> <head> <meta charset=”UTF-8″/> <script src=”C:UsersMarianoDesktopjsonmasmasmasdatos.js”></script> <script src=”select.js” type=”text”javascript”></script> </head>…
Read more