How to change the root password for MySql under Linux in the command line

You will need to know the current root password in order to change it In the command line type in and execute the following command mysqladmin -u root -pOLD_PASSWORD password NEW_PASSWORD Replace OLD_PASSWORD with your old password and NEW_PASSWORD with your new password.

March 23, 2018 · 1 min · 43 words · icarnaghan

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 the below with the Version Number in the string mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using readline 5.2

March 23, 2018 · 1 min · 42 words · icarnaghan

How to drop a entire MySql Database on the command line in Linux

Login to the MySql command line using something like the following mysql -uUSERNAME -pPASSWORD Then execute the following command to Drop the desired Database DROP TABLE MYDATABASE; Replace MYDATABASE with the Database name that you want to Drop Note: Please note that this can’t be undone, so please create a backup before proceeding.

March 23, 2018 · 1 min · 53 words · icarnaghan

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 above will export a selected database to a file called outputFile.sql mysqldump = a database backup program -u = Username for the database -p = Password for the database DatabaseName = The database name you wish to export

March 23, 2018 · 1 min · 60 words · icarnaghan

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 your password, MYSQLDATABASE with the database name you want to export andFILE_NAME.sql with the file that you wish to export the schema to.

March 23, 2018 · 1 min · 47 words · icarnaghan

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 will use DATETIME fields in a MySQL table field to track the dates of events. What happens if you need to display the date in Human readable format? By using the DATE_FORMAT() function you’ll be able to manipulate the Date in almost any possible way. ...

March 23, 2018 · 2 min · 327 words · icarnaghan

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 rows then this could come in handy. SELECT * FROM ads ORDER BY RAND() LIMIT 3 We’ve used the RAND() function to return random table rows

March 23, 2018 · 1 min · 45 words · icarnaghan

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 < import.sql Windows mysql -u username -p databasename < import.sql

March 23, 2018 · 1 min · 31 words · icarnaghan

How to output my MySql query results to a CSV file on the command line

Type in the following command SELECT id,clientid,company FROM config INTO OUTFILE '/tmp/List.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; The command above will output the results from the MySql query into a Comma Separated File called List.csv, it will split the columns by using a comma “,” and will terminate every new line with the line break character \n

March 23, 2018 · 1 min · 60 words · icarnaghan

How to rename a table in MySQL

RENAME TABLE oldTable TO newTable; Replace oldTable with the table’s name that you want to rename and newTable with the new table name.

March 23, 2018 · 1 min · 23 words · icarnaghan