To login to mysql without selecting a database
mysql -h hostname -u username -p
(hostname can be an IP addrress)
To create a new database, and user and grant permissions on that database to the new user.
create database moodle;
create user 'moodle'@'localhost' identified by 'password';
grant all privileges on moodle.* to 'moodle'@'localhost';
To run the sql script in the file text_file.sql in the database databasename:
mysql -h hostname -u username databasename -p < text_file.sql
To create a table:
CREATE TABLE categories (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
created_on DATE,
created_by INTEGER REFERENCES user(id),
modified_by INTEGER REFERENCES user(id),
modified_on DATE
);
mysql -h hostname -u username -p
(hostname can be an IP addrress)
To create a new database, and user and grant permissions on that database to the new user.
create database moodle;
create user 'moodle'@'localhost' identified by 'password';
grant all privileges on moodle.* to 'moodle'@'localhost';
To run the sql script in the file text_file.sql in the database databasename:
mysql -h hostname -u username databasename -p < text_file.sql
To create a table:
CREATE TABLE categories (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
created_on DATE,
created_by INTEGER REFERENCES user(id),
modified_by INTEGER REFERENCES user(id),
modified_on DATE
);
No comments:
Post a Comment