download mysql in ubuntu

36

sudo apt update
sudo apt install mysql-server
sudo service mysql start
sudo mysql_secure_installation
sudo mysql -u root 

In mysql console:
DROP USER 'root'@'localhost';
CREATE USER 'root'@'%' IDENTIFIED BY 'YOURPASSWORD';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
# Installing MySQL
sudo apt update
sudo apt install mysql-server

# — Configuring MySQL
sudo mysql_secure_installation
|-----> # Creating a Dedicated MySQL User and Granting Privileges
|		sudo mysql, mysql -u root -p,sudo mysql --defaults-file=/etc/mysql/debian.cnf
|		CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
|		# Change User Password
|		ALTER USER 'user_name'@'localhost' IDENTIFIED BY 'newPassword';
|		FLUSH PRIVILEGES;
|		# IF ERROR 1819 (HY000): Your password does not satisfy
|		# The current policy requirements (Source: ostechnix.com)
|		SET GLOBAL validate_password.policy = 0;
|		SET GLOBAL validate_password.length = 6; # If Required.
|		SET GLOBAL validate_password.number_count = 0; # If Required.
|		SHOW VARIABLES LIKE 'validate_password%'; # Show password level.
|
|		# Granting privileges
|		GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';
|		SHOW GRANTS FOR 'user'@'localhost';
|		FLUSH PRIVILEGES;
|		
|		# Delete User
|		DROP USER 'user'@'localhost';
|		# Show All Users
|		SELECT User, Host FROM mysql.user;
|		
|-----> # Creating database
|		create database db_name;
|		# Show DataBase
|		SHOW DATABASES;
|		# Delete Database
|		DROP DATABASE db_name;
|-----> # Creating table
|		USE db_name;
|		CREATE TABLE t_name (id int, name varchar(100));
|		# Insert Data
|		INSERT INTO t_name VALUES (1, 'AliRaza');
|		# Delete Table
|		DROP TABLE t_name;
|		# Show All tabales in DB
|		USE db_name;
|		SHOW TABLES;
|
|-----> # Import Sql File
|		mysql -u username -p db_name < file.sql
|
|-----> # Export Sql Database
|		mysqldump -u username -p db_name > file.sql # Full DB
|		mysqldump -u username -p db_name table_name > file.sql # Specific Table

Comments

Submit
0 Comments

More Questions

mysql format datemysql grant all privileges to a user finding duplicate column values in table with sql
mysql format dateorder by sql mysql show all tables
get all table name in sql through phpmysql show tables in database select count of distinct values sql
import database through command linesql server substring rename table sql
selecting name that contain certain word in sqlinstall sqlite3 python select duplicates in sql
ERROR 2002 (HY000): Cant connect to local MySQL server through socket -tmp-mysql.sock (2)alter table add foreign key mysql mysql delete row
how to auto increment in sqlhow to install mysql ubuntu sql where contains
how to create a table structure from another table in mysqlselect nextval from sequence sql truncate table
install sqlite npmpostgresql check total storage GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
how to select one row in mysqlselect row from mysql where date more than 30 days sql view where tables have same column name combine results
python mysql check if database existsdrop table if exists mysql month name extract
SQL SERVER Add Identity Column to existing tableupdate using case in mysql No module named MySQLdb
sql count duplicate rowshow to install postgresql on wsl group_concat limit mysql
sort by sqlquery to list all tables in sql database SELECT User,Host FROM mysql.user;
create a view in sqlitemysql get last insert id SQL UPDATE Statement
mysql show table column full descriptionpostgressql uuid t sql get foreign key