When you try to access MySQL database server from client such as mysql or even programming language such as php or perl you need a user account. MySQL has sophisticated user management system that controls who can access server and from which client system. It uses special tables in mysql database. In order to create a new user account you need a MySQL root account password.
Next you need to use the GRANT SQL command to set up the MySQL user account.
Finally, use the account's name and password to make connections to the MySQL server.
Please note that MySQL user accounts are different from UNIX/Linux login accounts. For example, the MySQL root user and the Linux/Unix root user are separate and have nothing to do with each other, even though the username is the same in each case.
Procedure for setting up a MySQL user account
Login in as mysql root user (at shell prompt type following command:):
$ mysql -u root -p
OR
$ mysql -u root -h myserver-sever.com -p
Create a new mysql database called demo
mysql> CREATE DATABASE demo;
Create a new user called user1 for database demo
mysql> GRANT ALL ON demo.* TO user1@localhost IDENTIFIED BY 'mypassword';
Note: GRANT ALL means all privileges i.e. user is permitted do anything. She can read, modify or delete data, but only on tables in the demo database. She cannot access any other database.
How do I connect to MySQL server using user1 account?
User user1 can connect to mysql server demo database using following command:
$ mysql -u user1 -p demo
OR
$ mysql -u user1 -h mysql.server.com -p demo
Where,
- -u user1: MySQL Username
- -h : MySQL server name (default is localhost)
- -p : Prompt for password
- demo: demo is name of mysql database (optional)
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop







![MySQL Import Command [ Database Import ]](http://s13.cyberciti.org/images/shared/rp/3/15.jpg)

![[ERROR] /usr/local/libexec/mysqld: unknown variable ‘thread_concurrency=8′](http://s13.cyberciti.org/images/shared/rp/3/5.jpg)


{ 14 comments… read them below or add one }
how to install & configure PHP on RHEL 4
Thanks! Simple and clear
its cool .v good
Excellent…!!
Its very easy and clear
hi , i want to configure a policy for users that expire password off users in specific time any one can help me ? (im using ubuntu 10.04 and mysql)
Please am trying to set up a mysql account to use in installing joomla to no avail . Please can someone help me with that ?
thanx yar.its a simple installation
Its very simple and valueable. Wroks fine for me. Thanks a lot.
nice man :)
very fine, thank you very match;
Hi I am new to mysql,
When I try to connect from command line. I need to enter my root password. I have created the demo database, but when I type “mysql -u user1 -p demo”, It shows me ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ‘mysql
-u user1 -p demo’ at line 1. Please help, how can I connect with this user1 to demo database in command prompt.
you need to grant the privilege of operating the database’demo’ to the user in the root model, like this: grant all on demo(name of your database) to user1(username)@ “localhost ” identified by “password”(your account’s password).
if you don’t have the primaryl syntax error,it should be a problem of your MySql version,which may be too old,then you can change a new release.
Excellent, quick how-tos. Thank you very Much!