Found 4219 Articles for MySQLi

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

130 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

230 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

199 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

226 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

161 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

188 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

182 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

How can we change MySQL user password by using the ALTER USER statement?

mkotla
Updated on 20-Jun-2020 11:41:28

276 Views

We can also use ALTER USER statement along with IDENTIFIED BY clause to change MySQL user password. Its syntax would be as possible −SyntaxALTER USER user_name@host_name IDENTIFIED BY ‘new_password’Here, New_password would be new password we want to set for MySQL userUser_name is the name of a current user.Host_name is the name of the host of a current user.ExampleSuppose if we want to change the password user@localhost to ‘tutorials’ then it can be done as follows −ALTER USER user@localhost IDENTIFIED BY ‘tutorials’

Advertisements