Well it's obvious from the error message that gallery2 is a PHP web-based gallery. (you know, photos, vidoes, and other graphical knick-knacks)
First off, are you sending the right user name and password to mysql?
Secondly, does that user (the user is in MySQL) have permission to access files from the remote host.
(the error refers to localhost, but the error could just as well say myhost.org or something if you were
trying to access your gallery from the outside world and myhost.org was your server name)
did you install MySQL your self, or did it come pre-packaged by your distro?
if you installed it your self first you need to run (as the system root user)
if you have yet to login to your mysql then you need to do so as the mysql root user and setup the mysql-root password
*note, that's the MySQL root user, not your systems root user.
(however you may need to be system root (su) in order to run mysqladmin)
Anyhow login as the mysql root and set your password like this:
mysqladmin -u root password 'new-password'
ok, now you are ready to do some real setup regarding gallery2's mysql database
First you need to setup the database that gallery2 uses
do you know what this is called? it should be in the gallery2 config files or in the documentation
if you need to make one then the command is:
mysqladmin -h localhost -u root -ppassword create gallerydatabasename
obviously replace "gallerydatabasename" with the right name for gallery2's database.
first off start mysql client as the root user with
mysql -h localhost -u root -ppassword
* note the lack of space between "-p" and "password"
once logged in it will provide you with a nice prompt of
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.41
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
now we can add a user for gallery2
GRANT ALL PRIVILEGES ON gallery2databasename.* TO 'gallery2'@'%' IDENTIFIED BY 'some_password';
the 'gallery2'@'%' will provide access to the usernamed gallery2 on all hosts (probably what you want)
next is to flush the grant table
and finaly quit mysql client
and that should set your mysql up enough to get gallery2 working