Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Thursday, June 21, 2012


MySQL Issues In Ubuntu

1) To install MySQL, run the following command from a terminal prompt.
sudo apt-get install mysql-server

2) If you need to check whether the MySQL server is running in your machine,  run the following command from a terminal prompt.
sudo netstat -tap | grep mysql

If you get the following reply, it is running.
tcp    0        0     localhost.localdomain:mysql    *:*     LISTEN -


To start the server type below.
sudo /etc/init.d/mysql restart

3) To stop the server type below.
sudo /etc/init.d/mysql stop

4) How to log in to MySQL
mysql -u root -p;



5) How to retrieve users list in mysql
select User from mysql.user;

6) How to create new user account
CREATE USER Ish IDENTIFIED BY PASSWORD 'ish';

7) How to check existing databases
show databases;

8) How to grant all privileges to a user
GRANT ALL ON TEST.* TO 'Ish'@'localhost';

8) How to grant specific privileges to a user
GRANT SELECT,INSERT,UPDATE,DELETE ON TEST.* TO 'Ish'@'localhost';

9) How to log in as a different user
mysql -u USERNAME -p;
(here it will prompt for the password)