Friday, 26 April 2024

Errors in Nginx

1. sudo systemctl restart nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details

=> fix:

$ sudo fuser -k 80/tcp
- this command kills processes that are currently using port 80
$ sudo fuser -k 443/tcp
- this command kills processes that are currently using port 443
$ sudo service nginx restart

Thank you.

Monday, 22 April 2024

Npm install errors sill idealTree buildDeps

Run commands

npm config set strict-ssl false

npm config set registry http://registry.npmjs.org/

Thank you

Fulltext Search in Mysql

1. What to use Fulltext Search for?

- Using for searching of text data in a large volumes, for text data stored in columns of type Char, Varchar, Text.

- Mode search in Fulltext search:

+ Natural language
+ Boolean search

- How Fulltext search working, ex:
We have 3 documents D1, D2, D3

D1 = "This is first document"
D2 = "This is second one"
D3 = "one two"

=> inverted index of 3 documents is:

"this" => {D1, D2}
"is" => {D1, D2}
"first" => {D1}
"document" => {D1}
"second" => {D2}
"one" => {D2, D3}
"two" => {D3}

=> search result of "this is first" is

{D1, D2} union {D1, D2} union {D1} = {D1}

- N-gram technique

 - Is technique device a string to children strings has same length (N) example: unigram (N=1), bigram (N=2), trigram (N=3). Ex apply when search Japanese language (because Japanese don't has space)

- Morphological Analysis: Using for searching natural language.

2. How to use Fulltext Search?

CREATE TABLE documents (
id INT AUTO_INCREMENT,
content TEXT,
PRIMARY KEY (id),
FULLTEXT (content)
);

-- Perform a Full-Text Search
SELECT * FROM documents WHERE MATCH(content) AGAINST('search query');

3. What does Fulltext Search include? 

Thank you

Explain statement in Mysql

1. What to use Explain statement for?

- Using explain in mysql to obtain information about how Mysql execute a select statement.
- Information Explain Statement provide:
+ Type: follow all->index->range->ref->eq->ref->const->system.
+ select_type: SIMPLE for simple select; SUBQUERY for a subquery
+ Rows: number of rows checked
+ Table: table involved in the select operation.
......

2. How to use Explain statement ?

EXPLAIN SELECT * FROM my_table WHERE id = 1;

Example

explain SELECT * FROM `order_info` WHERE note LIKE 'keywork'

explain SELECT * FROM `order_info` WHERE client_id = 1

3. What does Explain statement include? 

Thank you

Mysql tutorial from basic to advanced

1. Outline learning Mysql
- Mysql 

- Fulltext Search in Mysql

- Explain statement in Mysql

- Configuration for Quick add in Laragon

- Install Mysql for Ubuntu

- Install Mysql for Laragon

- Guide to install Apache2, Php 8.1, MySql 5.6, Mssql driver

- Remote MySQL database connection 

- Config SSL / TLS for MySQL on Ubuntu

2. What to use Mysql for?

3. How to use Mysql ?

(1) sudo nano /etc/mysql/my.cnf

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

(2) sudo nano /etc/mysql.conf.d/mysqld.cnf
  
#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
#
# * Basic Settings
#
user            = mysql
# pid-file      = /var/run/mysqld/mysqld.pid
# socket        = /var/run/mysqld/mysqld.sock
# port          = 3306
# datadir       = /var/lib/mysql


# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir                = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0
mysqlx-bind-address     = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
# max_allowed_packet    = 64M
# thread_stack          = 256K

# thread_cache_size       = -1

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP

# max_connections        = 151

# table_open_cache       = 4000

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
# general_log_file        = /var/log/mysql/query.log
# general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
# slow_query_log                = 1
# slow_query_log_file   = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
# server-id             = 1
# log_bin                       = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds    = 2592000
max_binlog_size   = 100M
# binlog_do_db          = include_database_name
# binlog_ignore_db      = include_database_name

Explain config

4. Quizzes for Mysql

- MySQL Quiz (part 01)

5. Errors in Mysql 

- SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (in Mysql 5.6) 

 

Reference
- https://www.jenkins.io/doc/tutorials/
- https://www.tutorialspoint.com/jenkins/index.htm

Thank you

MySQL Quiz (part 01)

Answers at bottom of Quiz.

1. What does SQL stand for?

    A. Structured Language
    B. Standardized Query Language
    C. Sequential Query Language
    D. Systematic Question Language

2. Which keyword is used to retrieve all columns in a SELECT statement?

    A. SELECT *
    B. SELECT COLUMN
    C. SELECT ALL
    D. SELECT FIELDS

3. What is the primary purpose of the WHERE clause in a SQL query?

    A. To filter results based on conditions
    B. To order results alphabetically
    C. To select specific columns
    D. To group results by a certain attribute

4. Which data type is used to store whole numbers in MySQL?

    A. INT
    B. FLOAT
    C. VARCHAR
    D. BOOLEAN

5. What is the purpose of the ORDER BY clause in SQL?

    A. To filter results
    B. To sort results
    C. To join tables
    D. To limit the number of results

6. In MySQL, what does the term "foreign key" refer to?

    A. A key that is unique across all tables
    B. A key used for encryption
    C. A column that points to the primary key in another table
    D. A key used for sorting data

7. Which SQL statement is used to update data in a table?

    A. MODIFY
    B. UPDATE
    C. ALTER
    D. CHANGE

8. What is the purpose of the GROUP BY clause in a SQL query?

    A. To filter results
    B. To group results based on a column
    C. To order results
    D. To join tables

9. Which function is used to find the total number of rows in a table?

    A. COUNT()
    B. SUM()
    C. AVG()
    D. TOTAL()

10. What is a stored procedure in MySQL?

    A. A temporary table
    B. A group of SQL statements that can be executed together
    C. A way to create virtual columns
    D. A method for indexing tables

11. What is normalization in the context of databases?

    A. The process of simplifying complex queries
    B. The process of organizing data to minimize redundancy
    C. The process of encrypting data for security
    D. The process of optimizing database performance

12. How is a JOIN different from a subquery?

    A. A JOIN is used for combining rows from different tables, while a subquery is used to return a single value.
    B. A subquery is used for combining rows from different tables, while a JOIN is used to return a single value.
    C. A JOIN and a subquery are the same thing.
    D. A JOIN is only used with numeric data, while a subquery works with any data type.

13. What is the purpose of the HAVING clause in a SQL query?

    A. To filter results based on conditions
    B. To order results alphabetically
    C. To filter results after a GROUP BY clause
    D. To select specific columns

14. How can you optimize a slow SQL query?

    A. Add more indexes
    B. Remove the WHERE clause
    C. Use the DISTINCT keyword
    D. Increase the number of columns in the SELECT statement

15. What is a transaction in MySQL?

    A. A single SQL statement
    B. A group of SQL statements that are executed together
    C. A sequence of database operations that are executed as a single unit
    D. A type of table used for logging changes to the database

16. What is the purpose of the LIMIT clause in a SQL query?

    A. To filter results based on conditions
    B. To limit the number of rows returned
    C. To group results based on a column
    D. To order results alphabetically

17. How can you add a new column to an existing table in MySQL?

    A. ALTER TABLE ADD COLUMN
    B. INSERT INTO
    C. MODIFY TABLE
    D. CREATE COLUMN

18. What is the difference between INNER JOIN and LEFT JOIN in MySQL?

    A. INNER JOIN only returns matching rows, while LEFT JOIN returns all rows from the left table and matching rows from the right table.
    B. INNER JOIN returns all rows from both tables, while LEFT JOIN only returns matching rows.
    C. INNER JOIN and LEFT JOIN are interchangeable terms.
    D. INNER JOIN and LEFT JOIN have no functional difference.

19. What is the purpose of the INDEX keyword in MySQL?

    A. To create a new table
    B. To define a primary key
    C. To improve query performance by creating an index on a column
    D. To count the number of rows in a table

20. How can you retrieve unique values from a column in MySQL?

    A. SELECT UNIQUE(column_name)
    B. SELECT DISTINCT column_name
    C. SELECT UNIQUE VALUES(column_name)
    D. SELECT DISTINCT VALUES(column_name)

21. What is a trigger in MySQL, and how is it used?

    A. A trigger is an event that fires automatically in response to certain actions on the database, such as INSERT, UPDATE, or DELETE operations.
    B. A trigger is a special type of stored procedure used for complex calculations.
    C. A trigger is a method for encrypting sensitive data in the database.
    D. A trigger is a way to schedule automated backups.

22. How does the concept of ACID properties relate to database transactions?

    A. ACID properties ensure that transactions are processed in alphabetical order.
    B. ACID properties ensure the consistency, isolation, and durability of database transactions.
    C. ACID properties are only relevant to non-relational databases.
    D. ACID properties are used to encrypt data in a database.

23. Explain the difference between a view and a table in MySQL.

    A. A view is a virtual table based on the result of a SELECT query, while a table is a physical storage structure.
    B. A table is a virtual structure used for complex queries, while a view is a physical storage structure.
    C. . A table and a view are the same thing.
    D. A view is used to store data permanently, while a table is temporary.

24. What is the purpose of the EXPLAIN statement in MySQL?

    A. To display information about the database schema
    B. To provide details about the execution plan of a query
    C. To retrieve data from multiple tables
    D. To create a graphical representation of the database structure

25. How can you ensure data integrity in a MySQL database?

    A. By regularly updating all records
    B. By using the CHECK constraint
    C. By avoiding the use of primary keys
    D. By allowing NULL values in columns

26. What is the purpose of the UNION operator in SQL?

    A. To combine rows from two or more tables without duplicates
    B. To update data in a table
    C. To order the results of a query
    D. To group rows based on a specific condition

27. Explain the concept of database normalization and its benefits.


    A. Database normalization is the process of organizing data to minimize redundancy and dependency. Benefits include improved data integrity and reduced data duplication.
    B. Database normalization is a method for optimizing query performance by creating indexes. Benefits include faster data retrieval.
    C. Database normalization is the process of encrypting sensitive data. Benefits include enhanced security.
    D. Database normalization is a way to create backups of the database. Benefits include data recovery in case of a failure.

28. What is the purpose of the TRUNCATE statement in MySQL?

    A. To remove specific rows from a table based on a condition
    B. To delete all rows from a table without logging individual row deletions
    C. To alter the structure of a table
    D. To update data in a table

29. How does the concept of indexing contribute to database performance?

    A. Indexing is used to define a primary key for a table.
    B. Indexing has no impact on database performance.
    C. Indexing speeds up the retrieval of rows by creating a data structure that allows for quicker data access.
    D. Indexing is used to encrypt sensitive data in the database.

30. What is a stored function in MySQL, and how is it different from a stored procedure?


    A. A stored function is a set of SQL statements that can be executed together. It is the same as a stored procedure.
    B. A stored function is a way to create virtual columns in a table. It is different from a stored procedure, which performs a series of actions.
    C. A stored function is a group of SQL statements that return a single value. It is different from a stored procedure, which can return multiple values.
    D. A stored function is a temporary table used for complex queries. It is the same as a stored procedure.

Answers: 1B; 2A; 3A; 4A; 5B; 6C; 7B; 8B; 9A; 10B; 11B; 12A; 13C; 14A; 15C; 16B; 17A; 18A; 19C; 20B; 21A; 22B; 23A; 24B; 25B; 26A; 27A; 28B; 29C; 30C;

Thank you 

Sunday, 21 April 2024

Building Applications, Software Systems & News Websites, E-commerce Websites

Are you seeking solutions to kickstart or enhance your business in the digital age? Let us accompany you on this journey!!

At Devlearn.vn, we specialize in providing comprehensive software development solutions, from mobile applications, enterprise software systems to news websites and e-commerce websites. With years of experience and a team of professional IT engineers, we are confident in turning your ideas into reality.

Our Services Include:

  • Website Design & Development: News websites, e-commerce websites, personal websites, and more.
  • Mobile App Development: iOS, Android, and cross-platform applications.
  • Enterprise Software Systems: Warehouse management, HR management systems, CRM, and other software solutions suitable for any industry.

Why Choose Us?

  • Guaranteed Quality: All products undergo rigorous testing to ensure the highest quality.
  • Advanced Technology: Utilizing the latest and most advanced technologies in software and web development.
  • Dedicated Support: Our customer support team is always ready to answer questions and provide technical assistance.

Don't hesitate! Contact us today for a free quote and start the digital transformation journey for your business.

📞 Hotline : 0971.793.662
📧
Email : phong2018@gmail.com
🌐
Website: www.devlearn.vn

Devlearn.vn - Your technology partner in the digital world. Connect now to unleash your potential!

Thank you sincerely.

Thursday, 18 April 2024

Configuration for Quick add in Laragon

Tools / Quick add / Configuration..
-----------------------------------------

#PHP
php-5.5=https://windows.php.net/downloads/releases/archives/php-5.5.38-Win32-VC11-x64.zip
php-5.6=https://windows.php.net/downloads/releases/archives/php-5.6.40-Win32-VC11-x64.zip
php-7.0=https://windows.php.net/downloads/releases/archives/php-7.0.33-Win32-VC14-x64.zip
php-7.1=https://windows.php.net/downloads/releases/archives/php-7.1.33-Win32-VC14-x64.zip
php-7.2=https://windows.php.net/downloads/releases/archives/php-7.2.34-Win32-VC15-x64.zip
php-7.3=https://windows.php.net/downloads/releases/archives/php-7.3.33-Win32-VC15-x64.zip
php-7.4=https://windows.php.net/downloads/releases/archives/php-7.4.32-Win32-vc15-x64.zip
php-8.0=https://windows.php.net/downloads/releases/archives/php-8.0.29-Win32-vs16-x64.zip
php-8.1=https://windows.php.net/downloads/releases/archives/php-8.1.25-Win32-vs16-x64.zip
php-8.2=https://windows.php.net/downloads/releases/archives/php-8.2.12-Win32-vs16-x64.zip

------------------------------------------------------

#Nodejs
node-10=https://nodejs.org/download/release/latest-v10.x/node-v10.24.1-win-x64.zip
node-11=https://nodejs.org/download/release/latest-v11.x/node-v11.15.0-win-x64.zip
node-12=https://nodejs.org/download/release/latest-v12.x/node-v12.22.12-win-x64.zip
node-13=https://nodejs.org/download/release/latest-v13.x/node-v13.14.0-win-x64.zip
node-14=https://nodejs.org/download/release/latest-v14.x/node-v14.21.3-win-x64.zip
node-15=https://nodejs.org/download/release/latest-v15.x/node-v15.14.0-win-x64.zip
node-16=https://nodejs.org/download/release/latest-v16.x/node-v16.20.2-win-x64.zip
node-17=https://nodejs.org/download/release/latest-v17.x/node-v17.9.1-win-x64.zip
node-18=https://nodejs.org/download/release/latest-v18.x/node-v18.19.0-win-x64.zip
node-19=https://nodejs.org/download/release/latest-v19.x/node-v19.9.0-win-x64.zip
node-20=https://nodejs.org/download/release/v20.17.0/node-v20.17.0-win-x64.zip
yarn=https://github.com/yarnpkg/yarn/releases/download/v1.22.21/yarn-v1.22.21.tar.gz

------------------------------------------------------

# MySQL
mysql-8.0=https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-winx64.zip
mysql-5.7=https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.39-winx64.zip
mysql-5.6=https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.51-winx64.zip

------------------------------------------------------

# MongoDB https://www.mongodb.com/download-center/community
mongodb-4=https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.3.zip

------------------------------------------------------

# MariaDB
mariadb10=https://archive.mariadb.org/mariadb-10.9.8/winx64-packages/mariadb-10.9.8-winx64.zip
mariadb11=https://archive.mariadb.org/mariadb-11.3.1/winx64-packages/mariadb-11.3.1-winx64.zip

------------------------------------------------------

# Postgresql
postgresql-13=https://get.enterprisedb.com/postgresql/postgresql-13.5-1-windows-x64-binaries.zip
postgresql-14=https://get.enterprisedb.com/postgresql/postgresql-14.5-1-windows-x64-binaries.zip
postgresql-15=https://get.enterprisedb.com/postgresql/postgresql-15.5-1-windows-x64-binaries.zip
postgresql-16=https://get.enterprisedb.com/postgresql/postgresql-16.1-1-windows-x64-binaries.zip

------------------------------------------------------

# Tools
phpmyadmin=https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
dbeaver=https://dbeaver.io/files/dbeaver-ce-latest-win32.win32.x86_64.zip

------------------------------------------------------
#Go
go-1.24=https://go.dev/dl/go1.21.4.windows-amd64.zip

------------------------------------------------------
ruby=https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.3-x64-mingw32.7z
devkit=https://github.com/leokhoa/laragon/releases/download/portable/devkit.7z

------------------------------------------------------
java=https://github.com/leokhoa/laragon/releases/download/portable/jdk-8u131-windows-x64.7z

Thank you

Golang Advanced Interview Q&A