MySQL Archives - Ian Carnaghan

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...

Mar 23 · 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...

Mar 23 · 11 sec read >

How to import a generated MySQL file ‘.sql’ via the CLI (Command Line Interface)

Open a new Terminal Window if not already in Command Line Type in the command below Linux mysql -uusername -ppassword databasename <...

Mar 23 · 7 sec read >

How to check which version of MySQL you are running by using the CLI (Command Line Interface) on Linux

In the CLI (Command Line Interface) type in the command below and hit enter mysql --version The results should look similar to...

Mar 23 · 8 sec read >

How to export a MySql database to a file via the Command Line in Linux

Open a new Terminal Window Type in the following command {codecitation class=”brush: bash;”} mysqldump -uUsername -pPassword DatabaseName > outputFile.sql {/codecitation} The command...

Mar 23 · 12 sec read >

Error: “Ignoring query to other database” when running a mySql command in the command line

E.g. SELECT  * FROM users; or SHOW tables; In the command line make sure you used the correct syntax when connecting to...

Mar 23 · 9 sec read >

How to get random rows when querying a database table using MySQL

For example, if you have a table with 100 rows in it and you need to get 3 random...

Mar 23 · 8 sec read >

How to Export your MySQL database schema to a file using the Command Line

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...

Mar 23 · 12 sec read >

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

NOTE: Please note that this is done in the Command Line Interface. First login to the mySql server using...

Mar 23 · 29 sec read >