MySQL

How to format date fields using MySQL

Ever wondered how to change the output of the date format using MySQL? If you are constantly logging you’re data it’s more likely that you...
Ian Carnaghan
1 min read

How to backup a MySQL database in Ubuntu

Open a new Terminal Window. Type in the following command: mysqldump -h localhost -u root -pPASSWORD database > backup.sql This will backup the database to the file backup.sql -h...
Ian Carnaghan
11 sec read

How to import a generated MySQL file ‘.sql’ via…

Open a new Terminal Window if not already in Command Line Type in the command below Linux mysql -uusername -ppassword databasename < import.sql Windows mysql -u username...
Ian Carnaghan
7 sec read

How to check which version of MySQL you are…

In the CLI (Command Line Interface) type in the command below and hit enter mysql --version The results should look similar to the below with the Version Number in...
Ian Carnaghan
8 sec read

How to export a MySql database to a file…

Open a new Terminal Window Type in the following command {codecitation class=”brush: bash;”} mysqldump -uUsername -pPassword DatabaseName > outputFile.sql {/codecitation} The command above will export a selected...
Ian Carnaghan
12 sec read

Error: “Ignoring query to other database” when running a…

E.g. SELECT  * FROM users; or SHOW tables; In the command line make sure you used the correct syntax when connecting to mySql Correct example: mysql -uroot...
Ian Carnaghan
9 sec read

How to get random rows when querying a database…

For example, if you have a table with 100 rows in it and you need to get 3 random rows then this could come...
Ian Carnaghan
8 sec read

How to Export your MySQL database schema to a…

Use the following command in the Command Line Interface mysqldump --no-data --tables -uMYSQL_USER_NAME -pMYSQL_PASSWORD MYSQLDATABASE >> FILE_NAME.sql Replace MYSQL_USER_NAME with your username,  MYSQL_PASSWORD with your password, MYSQLDATABASE with the database name...
Ian Carnaghan
12 sec read

How-to create a MySQL database and assign user privileges…

NOTE: Please note that this is done in the Command Line Interface. First login to the mySql server using root. mysql -uroot -pROOT_PASSWORD Replace...
Ian Carnaghan
29 sec read