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 connection using php on a web page, connecting to a mysql table and retrieving the…
Read MoreRestart 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 command too service mysqld start service mysqld stop service mysqld restart or service mysql start…
Read MoreImport / 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 > all_databases_export.sql To import one of these mysql databases from the dump into a database: mysql…
Read MoreChange 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 method just uses the whole MySQL database rather than a WordPress export/import from within and…
Read MoreOptimise 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 once you know the key format, I recently took over a site that previously…
Read MoreAdd 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. Also instead of adding an extra admin account you can just change the admin password…
Read MoreHow 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 of the computer you are on, this is for MySQL 5.7 onwards: Stop MySQL sudo…
Read MoreImport 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 already installed a quick trip to the terminal will sort this out. Create the database…
Read MoreMySQL 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 hell, this more than likely happens if mysql is running and the OS is updated…
Read MoreFind 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 can be displayed in either the source code of the html or rendered on the…
Read More