Login as root user with below command.
mysql -u root -p

Create database with below command.
CREATE DATABASE db_name;

Check database using command.
show databases;

Create user using command.
CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;

Grant privileges to the created user.
GRANT ALL PRIVILEGES ON db_name.* TO ‘username’@’%’ WITH GRANT OPTION;
than
FLUSH PRIVILEGES;

Check grants using command.
SHOW GRANTS FOR ‘username’@’%’;

————————————–

Logging in a specific db port
mysql -h hostname -P port -u username -p db_name

show table information, like engine, version, row_format_rows etc.
SHOW TABLE STATUS WHERE Name = ‘tbl_name’

change table storage engine
ALTER TABLE tbl_name ENGINE=NDBCLUSTER;

Show current DB Port:
SHOW VARIABLES WHERE Variable_name = ‘port’;
or
netstat -nat |grep :3306
(Instead 3306 you can mention your port number that you are finding)

Show current mysql user:
SELECT USER();

Advertisements