MySQLi Articles

Page 330 of 341

Populating a table from query results in MySQL?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 582 Views

To populate a table from query results, use the following syntax:INSERT yourTableName(yourColumnName1, yourColumnName2, yourColumnName3, ..........N) SELECT yourColumnName1, yourColumnName2, yourColumnName3, ..........N FROM yourAnotherTableName;To understand the above syntax, let us create a table. The first table is as follows with some records. The query to create a table is as follows:mysql> create table PopulateTableDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Amount int,    -> ArrivalDateTime datetime,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.68 sec)Now you can insert some records in the table using insert command. The ...

Read More

How to add super privileges to MySQL database?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 8K+ Views

Firstly, check the MySQL database with DESC command. mysql>DESC mysql.db; The following is the output. +-----------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+---------------+------+-----+---------+-------+ | Host | char(60) | NO | PRI | | ...

Read More

How to take backup of a single table in a MySQL database?

George John
George John
Updated on 30-Jul-2019 693 Views

The backup of a table can be made with the help of backup table as well as mysqldump utility. The backup table concept was used in MySQL version 5.0 and its earlier version. Here, I am performing backup with the help of mysqldump. Firstly, we will open cmd with the help of shortcut key. The mysqldump will run at the cmd. Therefore, firstly open cmd with the help of shortcut key − windowskey+R; Here is the snapshot − Now, cmd will open − In this, the MySQL bin folder is present at the following location − ...

Read More

ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 14K+ Views

In the system, the root is defined by another name as well as password. Then the user is created as a root with the help of the create command. This will result in the ERROR 1396. The query for this is given as follows − mysql> create user 'root'@'localhost' identified by 'root123'; After executing the above query, the following error is obtained − ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost' The user can be created with another name and password successfully. This is given as follows − mysql> create user 'John'@'localhost' identified by ...

Read More

Advantages of using MySQLi over MySQL?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 4K+ Views

MySQLi is also known as MySQL improved Extension. It is a relational SQL database management system. It is often used inside PHP to provide an interface with the MySQL databases. Some of the reasons why MySQLi is famous are given below − MySQLi uses the standard form of the SQL language. MySQLi is free as it is released under an open source license. MySQLi can be easily used with PHP which is the most famous language for web development. MySQLi is a very powerful language and it can handle the functionality of powerful database packages. MySQLi can work with ...

Read More

Which one is preferred between a large table or multiple small tables in MySQL?

George John
George John
Updated on 30-Jul-2019 295 Views

It is very difficult to say whether to prefer one large table or multiple small tables. It depends − On the application we are using. On database normalization However, there are many key points, through which we can say that multiple small tables are good in that situation. Suppose many developers are going to develop multiple tables, then there is a need to split them into multiple small tables. A situation when you are giving authority to many developers. This authority is for different parts of data. In this case, a need arise to split into multiple small ...

Read More

Open MySQL root access from all hosts?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 988 Views

To open root access from all hosts, we need to change the database to “mysql” with the help of USE command. The syntax of USE command is as follows − USE anyDatabasename; Now, I will use predefined database ‘mysql’, which is as follows − mysql> use mysql; Database changed I have changed the database above. Here is the query to get root access from the entire host − mysql> UPDATE user set host='%' where host='localhost'; Query OK, 6 rows affected (0.19 sec) Rows matched: 6 Changed: 6 Warnings: 0

Read More

MyISAM versus InnoDB in MySQL?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 333 Views

Both are engine types. Here is the query by which we can get to know which engine type and tables are being used. Firstly, we will choose the database with the help of USE command − mysql> USE business; Database changed Here is the query through which we can know which table or engine is being used − mysql> SHOW table status; The following is the output +------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ |Name | Engine | Version | Row_format | ...

Read More

Error 1046 No database Selected, how to resolve?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 3K+ Views

The 1046 error occurs if you forget to select any database before creating a table. Let us see how and why this error occurs. We will try to create a table without selecting a database − mysql> CREATE table MyTable1 -> ( -> id int -> ); ERROR 1046 (3D000): No database selected Or mysql> INSERT into sample values(1); ERROR 1046 (3D000): No database selected Look at the output above, we are getting the same 1046 error: “No database selected” Now, we can resolve this error after selecting any ...

Read More

Shortcomings of mysql_real_escape_string?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 186 Views

The shortcoming of mysql_real_escape_string is as follows − It has main shortcoming in the modern API while we are making prepared statement. This has another shortcoming for every possible attack when you will typecast. Let us see the typecast syntax in MySQL − (TypeCast)mysql_real_escape_string($_REQUEST['anyColumnName'])); In the above syntax, we are typecasting, but in this case, it is not safer for every possible attack. The other cases include the following − It is not type safe. It is not for injection attack.

Read More
Showing 3291–3300 of 3,404 articles
« Prev 1 328 329 330 331 332 341 Next »
Advertisements