Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the MySQL built-in function 'current_user()' return a hostname containing a '%' symbol?

Tags:

mysql

hostname

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?

like image 233
Edmhs Avatar asked Jan 06 '11 14:01

Edmhs


People also ask

What does host mean in MySQL?

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).

What is the function to return the current username in MySQL?

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.

How do I find my MySQL username?

You can find the current user name with CURRENT_USER() function in MySQL. for Ex: SELECT CURRENT_USER();

How do I add a user to a MySQL database?

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.


1 Answers

SELECT @@hostname;

--mysql 4.1 didn't have this one.

like image 130
Joao Costa Avatar answered Oct 10 '22 20:10

Joao Costa