Web & Software Developer

Archive for “MySQL Code”

MySQL commands and SQL queries to help you manage your MySQL databases and tables.

GeoNames Data Dump Files – Usage Example

This is an example of how to use the GeoNames data dump files on your own server. This gives you the steps to import the GeoNames data into your own MySQL database. This example will only use the allCountries.txt data file from the GeoNames data download page. Go ahead and download that file, now. You … Read more →

MySQL Command Line Cheat Sheet

These are my most often-used MySQL commands and queries. Connect to MySQL on the command line (replace USERNAME with your own): (You will then be prompted to enter your MySQL password.) MySQL Databases List all databases on the command line: Create a database on the command line: Replace database_name, above, with your name of choice. … Read more →

Reset MySQL root password in Ubuntu/Linux Command Line

These are the terminal commands to reset your MySQL password for your “root” user. This is useful if you forgot your MySQL password on your local LAMP server. This is a fix for errors like these: ERROR 1045: Access denied for user: ‘root@localhost’ (Using password: NO) ERROR 1045: Access denied for user: ‘root@localhost’ (Using password: … Read more →

Insert Data Array Into MySQL Table Using PHP

Updated to use MySQL transactions, prepared SQL statments, and bound parameters. This lets you insert data from a PHP array into your MySQL database table. It will insert multiple rows into the table, where each row will take values from one array element. Before inserting, you must prepare your data into an array consisting of … Read more →