Tag Archives: USE

First, the database and table which exists:

USE dbname;
select * from Authentication;
+----+---------+--------------------+---------------+----------------------+
| id | userid  | password           | role          | email                |
+----+---------+--------------------+---------------+----------------------+
|  7 | user1   | ljkjkjhjhjdhfZn0mz | administrator | [email protected]       |
| 10 | user2   | gdgdgdgdgdg^4YU    | user          | [email protected]       |
| 11 | user3   | dsdsdsdsdsd8       | user          | [email protected]       |
+----+---------+--------------------+---------------+----------------------+

Now create the other table and its fields:

CREATE TABLE `Login` (
  `id` int(6) unsigned NOT NULL AUTO_INCREMENT,
  `TimeLoggedIn` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`),
  KEY `id_2` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;

Now duplicate the field id in Login and populate it with existing data from table Authentication.

INSERT INTO `Login` (`id`) SELECT `id` FROM `Authentication`;

Now create relation:

ALTER TABLE `Authentication` ADD FOREIGN KEY (`id`) REFERENCES `Login`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;

Select table and then do:

mysql> USE mytable;
mysql> SHOW GRANTS;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for [email protected] |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*C35CFFB1DAEDFFF922182562332B1D86A36BC0' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.05 sec)

Create a user and grant all privileges on table to him:
CREATE USER 'someuser'@'localhost' IDENTIFIED BY 'newpassword';
GRANT ALL ON episodestbl.* TO 'someuser'@'localhost';
FLUSH PRIVILEGES;

Start mysql with:

mysql -u user -pPASSWORD

To choose a database:

USE mysql;

where mysql is the db name

To display all tables in the chosen database

SHOW TABLES;

To display all columns in a table:

SHOW COLUMNS FROM `user`;

where user is the table name

Or a single step command:

SHOW COLUMNS FROM `user` FROM `databasename`;[/code]
To display data in a coloumn or field:
SELECT `gamma` FROM `user`;

Where user is the table name and gamma is the field or coloumn name

To display two coloumns or fields side by side, you do:

mysql> SELECT `user`,`password` FROM `user`;

where user and password are two columns in the table user.

To modify the global USE flags, set the USE variable in /etc/make.conf

You can set USE flags for individual packages by specifying the package name and USE flag, in /etc/portage/package.use (the file or directory may not exist).

Eg of /etc/portage/package.use

dev-db/mysql berkdb -java[/code]

The above example disables java use flag and enables berkdb for package dev-db/mysql.

If you want only a temporary USE flag during emerge of just the current package, you can specify the flag on the same command line where you specify the emerge:

USE="-java" emerge seamonkey[/code]

To view the current USE flags, run:

emerge --info

Once some USE flags have been set, one must make Portage see the new flags, with:

emerge --update --deep --newuse world[/code]