Last active
May 27, 2020 13:53
-
-
Save tareq3/3275115b8e850d7e8cf71f182908a84a to your computer and use it in GitHub Desktop.
mysql cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### For showing mysql verseio | |
``` | |
mysql --version | |
``` | |
### For using mysql cli | |
``` | |
mysql | |
``` | |
# Mysql Login as Root USER | |
``` | |
mysql -u root -p | |
``` | |
#### If mysql showing error make sure u have set mysql as environment variable : c:\xampp\mysql\bin | |
### for using mysql as an user | |
``` | |
mysql -u USER_NAME | |
``` | |
### for using mysql as an user | |
``` | |
mysql -u USER_NAME -p | |
``` | |
## Database Manipulation | |
### create database | |
``` | |
create database db_NAME; | |
``` | |
### create table | |
``` | |
create table table_NAME; | |
``` | |
``` | |
CREATE TABLE example ( id smallint unsigned not null auto_increment, name varchar(20) not null, constraint pk_example primary key (id) ); | |
``` | |
### for showing mysql databases | |
``` | |
show databases; | |
``` | |
### for using any database | |
``` | |
use database_NAME; | |
``` | |
### for showing tables under database | |
``` | |
show tables; | |
``` | |
### for describing any table | |
``` | |
desc TABLE_NAME; | |
``` | |
### for selecting and showing columns of a table | |
``` | |
select host, user, password from user; | |
``` | |
## For securing database access | |
1. delete all user where user column value is empty. | |
2. change the password of root user | |
``` | |
update user set password= PASSWORD('rakib72542') where user = 'root'; | |
``` | |
3. when password reseted restart mysql service | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment