Mysql
Mysql
MySQL is an open-source database management system, commonly installed as part of the popular LAMP
(Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query
Language) to manage its data.
update your package index, install the MySQL-server package, and then run the included security script.
At the command prompt, run the following command to launch the mysql shell and enter it as the root user:
mysql -u root -p
When you’re prompted for a password, enter the one that you set at installation time, or if you haven’t set one,
press Enter to submit no password.
The following MySQL shell prompt should appear:
mysql>
SHOW DATABASES;
USE employees;
Example:
Here, we will create a table named "cus_tbl" in the database "customers".
Note:
Here, NOT NULL is a field attribute and it is used because we don't want this field to be NULL. If you will try to
create a record with NULL value, then MySQL will raise an error.
The field attribute AUTO_INCREMENT specifies MySQL to go ahead and add the next available number to the
id field.PRIMARY KEY is used to define a column as primary key. You can use multiple columns separated by
comma to define a primary key.
SHOW tables;
DESCRIBE cus_tbl;
In this example, we add two new columns 'address" after surname and "salary" in after age column.
In this example, we modify the column surname to be a data type of varchar(50) and force the column to allow
NULL values.
6) RENAME table
1) Insert Query
insert into cus_tbl values(1,'abhi','zarkar','chandrapur','23','200000');
2) MySQL Update Query
To provide a specific user with a permission, you can use this framework:
delete a user
mysql> DROP USER ‘abhijit’@‘localhost’;
If you want to list of MySQL user information, including user permission information and all user's data.