Does MySQL have built in function to get host name?
Similar to
select user(); //this returns user@userip
Edit:
select current_user(); //returns [email protected].%
Last symbol is %
-- why?
The MySQL hostname defines the location of your MySQL server and database. If you want to connect to the information in a MySQL database, you'll need to know the hostname. Again, the hostname is usually localhost, which indicates that the database is running on the same server as your application (e.g. WordPress).
MySQL CURRENT_USER() Function The CURRENT_USER() function returns the user name and host name for the MySQL account that the server used to authenticate the current client. The result is returned as a string in the UTF8 character set.
You can find the current user name with CURRENT_USER() function in MySQL. for Ex: SELECT CURRENT_USER();
MySQL CREATE USER ExampleStep 1: Open the MySQL server by using the mysql client tool. Step 2: Enter the password for the account and press Enter. Step 3: Execute the following command to show all users in the current MySQL server. Step 4: Create a new user with the following command.
SELECT @@hostname;
--mysql 4.1 didn't have this one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With