MySQL






Installation :

Download from https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.19.0.msi

Choosing a Setup Type page : Developer default:  Server Only(with specific components) : Full:  Custom :
Check Requirements” screen : Install visual studio 2015 or above  to install the MySQL database server for visual studio
  Install python to install Python connector,
High availability screen : InnoDB cluster or Standalone MySQL Server. 
Type and Networking screen : Development Computer or Server Computer:(database servers and web servers ) or Dedicated Computer
  Port no.
Authentication Method screen, : Strong password Encryption for Authentication.
Accounts and Roles screen, : MySQL root account password. and  Add user.

Windows Service screen       : configure the MySQL server to run as a windows service,  windows service name  with standard system account

Sample and Example screen.    : Connect To Server--root/sysadmin user/pwd  and then Apply Configuration Screen --  Execute 
Product Configuration screen  : MySQL Server 8.0.19 and Sample and Example 8.0.19 


select “Start MySQL workbench after Setup” and “Start MySQL Shell after Setup”
MySQL workbench is the development tool which is used to querying the database and create database objects.

“Local instance MySQL80.” Click on it
 enter the credentials : MySQL@localhost@3306
Create database Demodatabase
 you can see the new database in the “SCHEMAS” pan

ApexSQL Database Power Tools for VS Code (extension for VS Code )  allows users to connect to MySQL and MariaDB instances, run queries ad explore database objects


Sample :
mysql -u userName -p
CREATE DATABASE myDatabase CHARACTER SET utf8 COLLATE utf8_unicode_ci;

mysql
mysql> GRANT CREATE TEMPORARY TABLES ON databaseName.* TO userName;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON databaseName.* TO userName;
mysql> GRANT EXECUTE ON databaseName.* TO userName;
quit


================================================

https://www.tutorialspoint.com/mysql/mysql-installation.htm


Imp Files : /etc/init.d/mysqld start    and  /etc/my.cnf File Configuration  

[root@host]# mysqladmin -u root password "new_password"
[root@host]# mysqladmin --version
[root@host]# mysql mysql> SHOW DATABASES;
[root@host]# mysql -u root -p   -- connection to your MySQL server,

export PATH = $PATH:/usr/bin:/usr/sbin



Check   : ps -ef | grep mysqld

Startup : root@host# cd /usr/bin
./safe_mysqld &

Shutdown:  root@host# cd /usr/bin
./mysqladmin -u root -p shutdown



[root@host]# mysqladmin -u root -p create TUTORIALS    -- create a database TUTORIALS    
[root@host]# mysqladmin -u root -p drop TUTORIALS

[root@host]# mysql -u root -p -- Select a database TUTORIALS    
Enter password:******
mysql> use TUTORIALS;



SHOW DATABASES
USE Databasename
SHOW TABLES
SHOW COLUMNS FROM tablename
SHOW INDEX FROM tablename
SHOW TABLE STATUS LIKE tablename\G


root@host# mysql -u root -p password;
Enter password:*******
mysql> use mysql;
Database changed

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP   --will add user zara in TUTORIALS Database(i.e schema)
   -> ON TUTORIALS.*
   -> TO 'zara'@'localhost'
   -> IDENTIFIED BY 'zara123';
or
mysql> INSERT INTO user 
   (host, user, password, 
   select_priv, insert_priv, update_priv) 
   VALUES ('localhost', 'guest', 
   PASSWORD('guest123'), 'Y', 'Y', 'Y');
Query OK, 1 row affected (0.20 sec)

mysql> FLUSH PRIVILEGES;


mysql> SELECT * FROM tutorials_tbl 
   -> INTO OUTFILE '/tmp/tutorials.txt';


Export / Import :
$ mysqldump -u root -p --no-create-info --tab=/tmp tutorials tutorials_tbl   --dump tutorials_tbl table from TUTORIALS DB to /tmp
$ mysqldump -u root -p TUTORIALS tutorials_tbl > dump.txt
$ mysqldump -u root -p TUTORIALS > database_dump.txt

$ mysqldump -u root -p --all-databases > database_dump.txt     : Backup all Databases on host

Using n/w : $ mysqldump -u root -p database_name  | mysql -h other-host.com database_name
Oldserver : $ mysqldump -u root -p database_name table_name > dump.txt
Newserver : $ mysql -u root -p database_name < dump.txt

Text File : mysql> SELECT * FROM passwd INTO OUTFILE '/tmp/tutorials.txt'
   -> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
   -> LINES TERMINATED BY '\r\n';