Categories
SQL

Connecting MySQL Workbench to Server MySQL

Use: GRANT ALL ON *.* to root@’%’ IDENTIFIED BY ‘your-root-password’; Use % as host if you don’t know where user is connecting from. Also make sure Mysql is running and that iptables is not blocking the port. The above solves this error: Host … is not allowed to connect to this MySQL server

Categories
SQL

PHP MySQL Query based on number of results returned

$sql = “SELECT * FROM tbl”; $result = mysql_query($sql); if (mysql_num_rows($result)==0) { //do this } else { //do that }

Categories
SQL

MySQL: How to Copy tables into seperate Schemas

To Copy a single table in a Schema into another existing Schema CREATE TABLE myschema.mytbl LIKE myschema2.mytbl; INSERT INTO myschema.mytbl SELECT * FROM myschema2.mytbl; To Copy all the tables in a Schema into another existing Schema   In cmd/terminal, dump the database mysqldump -u root -ppass myschema > /path/to/myschema.sql In cmd/terminal, use the new database […]