Basic MySQL operations I
Mar 31, 2009 MySQL
In this post, I will present few basic commands for MySQL administration. You’ll see how to create a database, create user, assign a database for specific user, etc. First I suppose that you have root password set and that you know it… (in next posts I will present few steps to set this password or to recover it…)
Log in to mysql console:
[root@hydra mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 248 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Here you can see server version (in this case 5.0.45). With next command you can see all databases
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | birds | | mysql | | private | | bdd1 | | test | +--------------------+ 6 rows in set (0.05 sec) mysql>
If you want to create a new database, enter next command (remember that all SQL commands must be terminated with ; )
mysql> create database db1; Query OK, 1 row affected (0.00 sec)
Now we need to assign a user to newly created database. Also, we need to grant him all privileges for this database but restrict access and operations on another databases (except test database)
mysql> CREATE USER 'db1'@'localhost' IDENTIFIED BY 'db1pass'; Query OK, 0 rows affected (0.02 sec) mysql> GRANT ALL PRIVILEGES ON db1.* TO 'db1'@'localhost' IDENTIFIED BY 'db1pass'; Query OK, 0 rows affected (0.01 sec) mysql> quit; Bye
After this you can repeat step from the beginning and test new user account. In next posts I will present phpMyadmin
How to test BIND version running on DNS server?
Mar 23, 2009 DNS
BIND, or Berkley Internet Name Domain, is an Internet naming system used for DNS, which allows you to find the sites you are looking for. BIND contains entries for DNS names, so for example, if you type www.bla.com into your browser, the record tells your browser at what IP address to find the site. If you need to test BIND version running on DNS server, you can use next commands:
Windows
nslookup -q=txt -class=CHAOS version.bind 192.168.51.250
Linux
#dig -t txt -c chaos VERSION.BIND @192.168.51.250
After this, you should get next answers
Windows
Server: my.server.net
Address: 192.168.51.250
version.bind text =
"9.3.4-P1"
version.bind nameserver = version.bindThe Linux users will have more details about server
[root@server ~]# dig -t txt -c chaos VERSION.BIND @192.168.51.250 ; <<>> DiG 9.3.4-P1 <<>> -t txt -c chaos VERSION.BIND @192.168.51.250 ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44906 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;VERSION.BIND. CH TXT ;; ANSWER SECTION: VERSION.BIND. 0 CH TXT "9.3.4-P1" ;; AUTHORITY SECTION: VERSION.BIND. 0 CH NS VERSION.BIND. ;; Query time: 54 msec ;; SERVER: 192.168.51.250#53(192.168.51.250) ;; WHEN: Mon Mar 23 20:09:57 2009 ;; MSG SIZE rcvd: 65
To hide your version of bind, add the following value to named.conf (now the commands shown above won’t return Bind version)
options {
.....
version "[SECURED]";
};Save named.conf and restarted named.
Remember the fact that Bind is the most popular Internet naming system but not the only one…
Hello world!
Mar 7, 2009 Other
# nano hello.sh
#!/bin/bash STR='Hello World!' echo $STR
# chmod +x hello.sh
[me@star ~]# ./hello.sh
Hello World!

