Welcome To My Blog
here i will try to collect as much as i can of articles and
toutorials talking about linux and open source software

if you want to share me this and be an author Contact me
subscribe to RSS or subscribe to Email Newsletter

Usefull basic Mysql commands

Posted by ahmedhamdy_27 Tuesday, December 15, 2009

Buzz It

here are some basic but useful MySQL commands.




How to login to MySQL:

mysql -u root -p

How to create a MySQL database via Shell:

After you logged in, execute this command (replace dbname with the name of the database you want to create):
mysql> create database dbname;

Output:
Query OK, 1 row affected (0.01 sec)

How to delete a MySQL database via Shell:

mysql> drop database dbname;

Output:
Query OK, 0 rows affected (0.05 sec)

How to create a MySQL User via Shell:

(replace dbusername with the username you want to create)
mysql> create user dbusername;

How to set a password for the MySQL User you just created:

(replace passhere with the password you would like to set)
mysql> set password for dbusername = password('passhere');

How to grant privileges for the username to the database:

mysql> grant all privileges on dbname.* to dbusername@localhost identified by 'passhere';

How to display database tables in a MySQL database?


First enter the database by executing:
mysql> use dbname;

Now show tables:
mysql> show tables; 

To search for a specific table without remembering its exact name:
(where keyword is the partial name you remember)
mysql> show tables in dbname like '%keyword'; 

How to exit MySQL via Shell:

mysql> exit

Blog Widget by LinkWithin
Add to Technorati Favorites
blog comments powered by Disqus
Loading...

BEST WAY TO SAY THANKS

Labels

ubuntu apache mysql backup gnome audio players compile kernel grub restore security themes web hosting 3d games Clonezilla centos cpanel database fun games gmail gzip kernel linux games mod_deflate monitoring tools music making open ssh recovery redhat reinstall grub rsync ssh * Apt-Get * Howto 3d acceleration AMANDA Ardour Bacula Duplicity E-Books Extract files from ISO FlyBack Graphics Card IP Failover and Web Cluste IP Failover and Web Cluster IPv6 Jokosher K9Copy KDE Karmic Linux Linux Set Date and Time Linux Tools Linux backup tools Linux commands Networking Nginx Open VPN Operating system PATH ReZound Remote Desktop Solutions for Linux Reverse Proxy Load Balancer SLAMPP Samba Sweep Time Vault Traverso DAW Ubuntu Tweak Webmin Windows vs Linux antivirus audi studio auto mount bash block ip block users blog editor boot caching check mail dangerous .caution dd deadly commands debian directory listing dns docks dvd easyapache error 18 fedora find fixing partitions table fork() bomb glxinfo hacking handbrake help image initrd install linux iptables jack jaunty lamp ldap lfs linus linux live linux vs windows log mac osx man mod_rewrite mount network boot ntfs open courseware open source books opengl openshot own distro packup php print in linux print over wireless ptr recompile redirect restore disk restore mbr reverse dns rip dvd screen server share desktop speed up linux spf ssmtp stream desktop swatch syslog syslog-ng top toutorials useful applications vi video editor vim vlc vmlinuz wallpapers whm xsplash

Recent Posts

archive

BEST WAY TO SAY THANKS