Found 4378 Articles for MySQL

What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?

Alankritha Ammu
Updated on 20-Jun-2020 11:58:11

95 Views

MySQL returns NULL if we provide any non-hexadecimal number as an argument to UNHEX() function. Following example will demonstrate it.Examplemysql> Select UNHEX('ANK96598'); +-------------------+ | UNHEX('ANK96598') | +-------------------+ | NULL              | +-------------------+ 1 row in set (0.00 sec)As we know that the valid hexadecimal digits are between ‘0…9’, ‘A…F’ or ‘a…f’ hence the above query returns NULL.

How can we remove all the prefixes or suffixes from a given string in MySQL?

Akshaya Akki
Updated on 20-Jun-2020 11:48:45

1K+ Views

MySQL TRIM() function is used to remove all the suffixes or prefixes or both from the string. The working of TRIM() function can be understood with the help of its syntax −SyntaxTRIM([{BOTH | LEADING | TRAILING} [str_to_remove] FROM] string)Here,  the argument BOTH means the prefixes from both left and right to be removed from the string.LEADING argument means that only leading prefixes to be removed.TRAILING argument means that only trailing prefixes to be removed.Str_to_remove is the argument which means the string we want to remove from the string.String argument means the string from which the prefixes have to be removed.Examplemysql> ... Read More

How can MySQL SUBSTRING() function be used with FROM and FOR keywords?

Chandu yadav
Updated on 10-Feb-2020 07:46:15

131 Views

The syntax of SUBSTRING() function using FROM and FOR keywords is the standard MySQL syntax.SyntaxSUBSTRING(str FROM pos FOR len)Here, str is the string from which substring would be returned.Pos is the starting position of substring.Len is the length of substring i.e. the total number of characters fetched from str.Examplemysql> Select SUBSTRING('foobarbar' FROM 4 FOR 5); +-------------------------------------+ | SUBSTRING('foobarbar' FROM 4 FOR 5) | +-------------------------------------+ | barba                               | +-------------------------------------+ 1 row in set (0.00 sec)The result set above, makes the use of FROM and FOR keywords very much clear in SUBSTRING() function.

How can we create a MySQL user account by omitting the hostname?

seetha
Updated on 20-Jun-2020 11:47:50

232 Views

If we omit the hostname part of the user account, MySQL will accept it and allow the user to connect from any host. Its syntax would be as follows −Use mysql; CREATE USER user_name IDENTIFIED BY password;Here, user_name is the name of the user we wish to take account of.Password is the password we wish to make for user_account. With the help of this password, MySQL server will identify this user.ExampleIn the given example we are creating a user ‘REMOTE’ by omitting the host name.mysql> CREATE USER remote identified by 'password123'; Query OK, 0 rows affected (0.00 sec)The user ‘Remote’ can ... Read More

How can we split the name string into three parts by using MySQL SUBSTRING_INDEX() function?

Sharon Christine
Updated on 20-Jun-2020 11:49:23

201 Views

To make it understand, we are using the following data from a table named ‘customerdetail’.mysql> Select * from Customerdetail; +----------------------+----------------------+----------+---------------------+ | Name                 | FName                | Address  | Emailid             | +----------------------+----------------------+----------+---------------------+ | Advik Jhamb          | Lovkesh Jhamb        | Mumbai   | Advik@gmail.com     | | Chirag Jai Patil     | Raman Jai Patil      | Gujrat   | chirahp@yahoo.com   | | Devansh Singh Rajput | Kishore Singh Rajput | ... Read More

How to allow a MySQL user account to connect from any host?

vanithasree
Updated on 20-Jun-2020 11:50:03

2K+ Views

It is quite possible to allow a user account to connect from any host. To do so we need to create the user with the help of ‘%’ wild card character after @ character. Its syntax would be as follows −Use mysql; CREATE USER user_name@’%’ IDENTIFIED BY password;Here user_name is the name of the user we wish to make an account for.Password is the password we wish to make for user_account. With the help of this password, MySQL server will identify this user.ExampleIn the given example we are creating a user ‘Gaurav’ by using ‘%’ character so that it can be ... Read More

How can we create user accounts in MySQL database server?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

227 Views

As we know that, MySQL database server is having the user table in MySQL database which is used to store the user accounts so by using MySQL database we can create user accounts in MySQL database server. There must be two things while creating the new user account, one is the username and other is the hostname which is after @ character. The syntax for creating the user account is as follows − Syntax Use mysql; CREATE USER user_account IDENTIFIED BY password; Here user_account is the name of the user we wish to take account of. It can ... Read More

Which tables are used to control the privileges of MySQL database server?

radhakrishna
Updated on 20-Jun-2020 11:50:56

162 Views

When we install MySQL server, a database named MySQL created automatically. This MySQL database contains five main grant tables with the help of which MySQL server can control the privileges of MySQL database server. These tables are as follows −user tableThis table contains user account and global privileges columns. MySQL uses the user table to either accept or reject a connection from a host. A privilege granted in the user table is effective to all databases on the MySQL server.db tableThis table contains database-level privileges. MySQL uses the db table to determine which database a user can access and from which host. ... Read More

How can we split the name string into two parts by using MySQL SUBSTRING_INDEX() function?

Fendadis John
Updated on 10-Feb-2020 07:22:10

189 Views

To make it understand, we are using the following data from a table named ‘customerdetail’.mysql> Select * from Customerdetail; +----------------------+----------------------+-----------+---------------------+ | Name                 | FName                | Address   | Emailid             | +----------------------+----------------------+-----------+---------------------+ | Advik Jhamb          | Lovkesh Jhamb        | Mumbai    | Advik@gmail.com     | | Chirag Jai Patil     | Raman Jai Patil      | Gujrat    | chirahp@yahoo.com   | | Devansh Singh Rajput | Kishore Singh Rajput ... Read More

How MySQL prevents unauthorized clients from accessing the database system?

Abhinaya
Updated on 20-Jun-2020 11:51:30

185 Views

MySQL implements a sophisticated access control and privilege system that allows us to create comprehensive access rules for handling client operations and effectively preventing unauthorized clients from accessing the database system.The MySQL access control has two stages when a client connects to the server −Connection verification A client, which connects to the MySQL database server, needs to have a valid username and password. In addition, the host from that the client connects needs to match with the host within the MySQL grant table.Request verificationonce a connection is established successfully, for each statement issued by the client, MySQL checks whether the client ... Read More

Advertisements