Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Wednesday, October 1, 2008

SQL

1. To use a database
use

2. To show all tables in the database
show tables from

3. Describe a table
describe

4. print some rows
select * from limit

Friday, July 11, 2008

create user/grant permission

login as root by....mysql -u root
create user 'username'@'hostname' identified by 'passwd';
create database mydb;
grant all on mydb.* to 'username'@'hostname';

now login as the new user and create table etc in mydb.
mysql -u username -p
enter password

installing/reinstalling/removal

Ubuntu packages: mysql-client-5.0. mysql-server-5.0
starting mysqld service... sudo /etc/init.d/mysqld start

to completely remove mysql do the following.
sudo apt-get --purge remove mysql-client mysql-server-5.0
you will loose all databases!!!

changing the directory in which mysql databases are stored

By default all databases are saved in /var/lib/mysql
Because this is in the root partition you might quickly use up root
partition if you create large databases. If you want to change this
directory to, for example, /home/mysql do the following.

creating the new datadir
sudo mkdir /home/mysql

stop mysql.
sudo /etc/init.d/mysql stop

edit my.cnf (mysql config file)
sudo emacs -nw /etc/mysql/my.cnf

change datadir under [mysqld] from /var/lib/mysql to /home/mysql

edit apparmour (Ubuntu speciality)
sudo emacs -nw /etc/apparmour.d/usr.sbin.mysqld
change lines that contain /var/lib/mysql/ to /home/mysql/

copy the databases to new directory.
sudo mv /var/lib/mysql/* /home/mysql/.

change file ownership (should be owned by user mysql and group mysql)
sudo chown -R /home/mysql

restart apparmour
sudo /etc/init.d/apparmour restart

start mysql
sudo /etc/init.d/mysql start

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1