How to connect to a MySQL or mariadb database with PHP

This tutorial will require a mysql database set up with a database user and password and a web development environment using mysql or mariadb, apache and php and a simple text editor. The tutorial takes you through establishing a mysql…
Restart Start Stop MySQL Server from Command Line, macOS, Linux

To restart, start or stop MySQL or mariadb database servers from the command line, type the following at the shell prompt… On Linux start/stop/restart from the command line: /etc/init.d/mysqld start /etc/init.d/mysqld stop /etc/init.d/mysqld restart Some Linux flavors offer the service…
Import / Export a mysql database on the command line

To export a mysql database (as a dump) from the command line run: mysqldump database_name > database_exportname.sql To import a mysql database dump into a database: mysql database_name < database_exportname.sql To export all databases into a dump: mysqldump –all-databases >…
Change and Update WordPress URLS in Database When Site is Moved to new Host

After migrating a WordPress site to a new URL either to a live production site or a testing development server, the new URL strings in the MySQL database need to be changed and updated in the various MySQL database tables. This…
Optimise wp_postmeta table and remove custom fields meta keys

Overtime a wp_postmeta WordPress database table may become bloated and use redundant custom field meta_keys. The table may have thousands of rows worth of dead data such as old custom fields.You can remove these keys quite quickly in the MySQL database…
Add WordPress Admin Account to Database wp_users Table

Here is a guide on how you can add in a newWordPress admin account username and password to the database. What you do need to do this have access to the WordPress database by having the database name and password.…
How to Change the MySQL root Password in Linux or macOS via Command Line

If you have forgot the MySQL root password, can’t remember or want to force it….. you can reset the mysql database password from the command line in either Linux or macOS as long as you know the root user password…
Import a mysql database into macOS via Terminal

Import a mysql/mariadb database into macOS via the command line I have found that phpmydmin on the Mac has issues with the max upload file size limit and changing the value in php.ini doesn’t always do the trick. With mysql…
MySQL ERROR! The server quit without updating PID file
ERROR! The server quit without updating PID file ERROR! MySQL server PID file could not be found! Getting these MySQL errors on your database server on macOS, there seems to be lots of solutions about how to fix this, Google…
Find out how many database queries per pageload in WordPress

To find out how many WordPress mysql database queries a page requests and how long it takes the page to load whilst querying the database, you can add in a PHP function to a WordPress hook to find out. This…