Found 4219 Articles for MySQLi

How can we change MySQL user password by using the SET PASSWORD statement?

Govinda Sai
Updated on 20-Jun-2020 11:42:26

245 Views

We can use SET PASSWORD statement to change the password. Before using this command, we need to have at least UPDATE privileges. Its syntax would be as follows −SyntaxSET PASSWORD FOR ‘user_name@host_name’=new_password;Here, New_password would be new password we want to set for MySQL userUser_name is the name of the current user.Host_name is the name of the host of the current user.ExampleSuppose if we want to change the password user@localhost to ‘tutorials’ then it can be done as follows −SET PASSWORD FOR ‘user@localhost’= tutorials;

How can I use SUBSTRING_INDEX() function to get the substring as output which is between two same delimiters in a string?

Samual Sam
Updated on 20-Jun-2020 11:40:33

177 Views

We need to use nested SUBSTRING_INDEX() function for getting the substring as output which is between two same delimiters in a string. For example, from the string ‘www.tutorialspoint.com’, we want the substring ‘tutorialspoint’, which is in between two same delimiters ‘.’ as output then SUBSTRING_INDEX() function can be used in nested form as follows −mysql> Select SUBSTRING_INDEX(SUBSTRING_INDEX('www.tutorialspoint.com','.',2),'.',-1)AS 'Nested SUBSTRING_INDEX'; +------------------------+ | Nested SUBSTRING_INDEX | +------------------------+ | tutorialspoint         | +------------------------+ 1 row in set (0.02 sec)

How can we split an IP Address into four respective octets by using MySQL SUBSTRING_INDEX() function?

Chandu yadav
Updated on 10-Feb-2020 07:11:38

613 Views

Suppose we have a table named ‘ipaddress’ which contains the IP addresses as its values in column ‘IP’ as follows −mysql> Select * from ipaddress; +-----------------+ | ip              | +-----------------+ | 192.128.0.5     | | 255.255.255.255 | | 192.0.255.255   | | 192.0.1.5       | +-----------------+ 4 rows in set (0.10 sec)Now with the help of SUBSTRING_INDEX() function in the following query, we can divide the IP address in four octets −mysql> Select IP, SUBSTRING_INDEX(ip, '.', 1)AS '1st Part',     -> SUBSTRING_INDEX(SUBSTRING_INDEX(ip, '.', 2), '.', -1)AS '2nd Part',     ... Read More

How MySQL SUBSTRING_INDEX() function returns the substring if we provide the negative value of the argument ‘count’?

Rama Giri
Updated on 10-Feb-2020 07:11:51

273 Views

MySQL SUBSTRING_INDEX() function can accept the negative value of argument ‘count’ and in this case, it returns the substring from the right of the final delimiter.Examplemysql> Select SUBSTRING_INDEX('www.google.com','.',-2); +------------------------------------------+ | SUBSTRING_INDEX('www.google.com','.',-2) | +------------------------------------------+ | google.com                               | +------------------------------------------+ 1 row in set (0.00 sec) mysql> Select SUBSTRING_INDEX('www.google.com','.',-1); +------------------------------------------+ | SUBSTRING_INDEX('www.google.com','.',-1) | +------------------------------------------+ | com                                      | +------------------------------------------+ 1 row in set (0.00 sec)

What is the use of FLUSH PRIVILEGES statement in MySQL?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:21

6K+ Views

Actually, we need to perform flush-privileges operation to tell the server to reload the grant tables. This can be done by issuing FLUSH PRIVILEGES statement or by executing a mysqladmin flush-privileges or mysqladmin reload command. FLUSH PRIVILEGES is really needed if we modify the grant tables directly using such as INSERT, UPDATE or DELETE, the changes have no effect on privileges checking until we either restart the server or tell it to reload the tables. But, Privileges assigned through GRANT choice don't want FLUSH PRIVILEGES to take effect - MySQL server cannotice these changes and reload the grant tables instantly. ... Read More

How can we change MySQL user password by using UPDATE statement?

Giri Raju
Updated on 20-Jun-2020 11:43:23

2K+ Views

To change MySQL user password with the help of UPDATE statement, we need to update the ‘user’ table of the ‘mysql’ database. Its syntax would be as follows −SyntaxUSE mysql; UPDATE user SET authentication_string = PASSWORD(‘new_password’) WHERE user = user_name AND host = host_name;The first two statements will be common because to change the password for MySQL user we need to use MySQL database and update the user table.New_password would be new password we want to set for MySQL userUser_name is the name of the current user.Host_name is the name of the host of the current user.ExampleSuppose if we want ... Read More

How can we get the list of tables in a particular database from MySQL Server command line?

Rishi Rathor
Updated on 10-Feb-2020 06:46:34

189 Views

We need to use ‘mysqlshow’ client program along with the name of the database to get the list of tables in a particular database. Its syntax would be as follows −Mysqlshow – u root db_name [pat_matching]Here db_name would be the name of the database from which we want to get the name of tables.Pat_matching is optional. It is used to get the list of the tables of some specific pattern. If we will not provide any pattern then it will show all the tables stored in that database.ExampleThe following command will get all the tables of database ‘query’ −C:\mysql\bin>mysqlshow -u ... Read More

How can we analyze the tables of a particular database from MySQL Server command line?

Ramu Prasad
Updated on 10-Feb-2020 06:48:01

176 Views

We need to use ‘mysqlcheck’ client program along with –analyze option to analyze the tables of a particular database. Its syntax would be as follows −Mysqlcheck – u root –analyze db_nameExampleThe following command will analyze the tables of database ‘query’ −C:\mysql\bin>mysqlcheck -u root --analyze query query.cars                            OK query.copy_cars                       OK query.countries                       Table is already up to date query.customers                   ... Read More

How can I check the status of MySQL Server?

Nancy Den
Updated on 10-Feb-2020 06:48:48

864 Views

With the help of ‘mysqladmin’ along with ‘status’ option program we would be able to check the status of MySQL server. It can be used as follows on command line −C:\mysql\bin>mysqladmin -u root status Uptime: 3865 Threads: 1 Questions: 50 Slow queries: 0 Opens: 113 Flush tables: 1 Open tables: 102 Queries per second avg: 0.012

What kinds of programs are available in MySQL database to manage MySQL server?

V Jyothi
Updated on 20-Jun-2020 11:44:48

62 Views

MySQL database provides us the following programs as administrative tools to manage MySQL server −mysqldIt is also known as MySQL server daemon. It is the main program that does most of the work in a MySQL installation. We need to use ‘mysqld’ to start our MySQL server. It is having many options that can be specified at the time of startup.mysqladminProcessing Re-write Suggestions Done (Unique Article)Basically ‘mysqladmin’ could be a client for playacting administrative operations. we are able to use it to see the server’s configuration and current status, to create and drop databases, and plenty of a lot of.For ... Read More

Advertisements