Restart MySql in Ubuntu
There are times when you might have a database connection error. If you are on the Ubuntu system on Amazon hosting then run this command. sudo service mysql or try this sudo /etc/init.d/mysql start
Read MoreArticles, commentary, and related writing filed under this topic.
Want to know when something new is published about terminal ? Enter your email address below and choose how often you would like to be notified.
We will send you a confirmation email. Your subscription does not become active until you confirm it.
There are times when you might have a database connection error. If you are on the Ubuntu system on Amazon hosting then run this command. sudo service mysql or try this sudo /etc/init.d/mysql start
Read More
In order to access your the mysql part in your terminal you will enter something like this. Access monitor: mysql -u [username] -p; (will prompt for password)
Read More
In order to show all databases in your terminal enter the following code. show databases;
Read More
If you're a developer working with databases, you're probably familiar with MySQL - an open-source relational database management system. While there are many ways to access a MySQL database, one of the most straightforward methods is through the MySQL te
Read More
If you want to create a new database in terminal enter the following command. create database [database];
Read More
You can select a database to work with by entering the following command in terminal. use [database];
Read More
If you want to know what database that you are in you can use this terminal command. select database();
Read More
If you want to see the tables in the database use this command. show tables;
Read More
To show the table structure in terminal use this code. describe [table];
Read More
To see all indexes on a table enter this code. show index from [table];
Read More
To create a new table with columns use this command. CREATE TABLE [table] ([column] VARCHAR(120), [another-column] DATETIME);
Read More
If you're working with a MySQL database, you may find that you need to add a new column to a table. Fortunately, adding a column to a MySQL table is a straightforward process that we will do using the MySQL terminal command. Here's how:
Read More
To insert a record use this command in terminal. Customize the values. INSERT INTO [table] ([column], [column]) VALUES ('[value]', [value]');
Read More
For date time input use this function. NOW()
Read More
To select record in terminal for mysql use this command. Change the value of table and take out the brackets. SELECT * FROM [table];
Read More
To explain records use this command. Take out brackets and replace table with your table name. EXPLAIN SELECT * FROM [table];
Read More
To export a database use this command in terminal. mysqldump -u [username] -p [database] > db_backup.sql If that does not work for you then you may have created a user in cPanel or some other website management application. You may have to use the --no-ta
Read More
To import a database dump use this command. mysql -u [username] -p -h localhost [database] < db_backup.sql
Read More
To select parts of records use this command. SELECT [column], [another-column] FROM [table];
Read More
To count records enter this command. Take out square brackets and replace names accordingly. SELECT COUNT([column]) FROM [table];
Read More
To count and select group records in terminal use this command. SELECT *, (SELECT COUNT([column]) FROM [table]) AS count FROM [table] GROUP BY [column];
Read More
To select specific records in terminal use this code. SELECT * FROM [table] WHERE [column] = [value];
Read More
To find records containing something use this command. SELECT * FROM [table] WHERE [column] LIKE '%[value]%';
Read More
To find something that starts with a certain string use this code. SELECT * FROM [table] WHERE [column] LIKE '[value]%';
Read More
To find records that start and end with a certain value use this command. SELECT * FROM [table] WHERE [column] LIKE '[val_ue]';
Read More
To select a range use this code. Take out the brackets and replace the values. SELECT * FROM [table] WHERE [column] BETWEEN [value1] and [value2];
Read More
To select with a customer order and limit the results use this command. SELECT * FROM [table] WHERE [column] ORDER BY [column] ASC LIMIT [value];
Read More
To update a record you can use this command. UPDATE [table] SET [column] = '[updated-value]' WHERE [column] = [value];
Read More
To delete records in mysql use this terminal command. DELETE FROM [table] WHERE [column] = [value];
Read More
For Custom Column Output Names Terminal MySQL, when selecting data from a table using the SELECT statement, you can customize the output column names. This can be useful when the column names in the table are not descriptive enough or when you want to for
Read More