On a Mac
To get help:
on mysqld command line options:
shell> mysqld --verbose --help
To start the server:
shell> mysqld_safe --basedir=<SQL Base DIR>
To shutdown:
shell> mysqladmin -u root shutdown
To execute queries:
shell> mysql --user=root mysql
With username and password:
shell> mysql --user=username mysql -p
To create a local user:
mysql> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
MySQL distinguishes between local users and users who can connect via the network:
mysql> CREATE USER 'username'@'%' IDENTIFIED BY 'password';
To create a database:
mysql> CREATE DATABASE db_name CHARACTER SET utf8;
Grant user access to database:
mysql> GRANT ALL PRIVILEGES ON db_name.* TO 'username'@'localhost' WITH GRANT OPTION;
Check grants:
mysql> SHOW GRANTS FOR 'username'@'localhost';
Need to flush it so it takes effect:
mysql> FLUSH PRIVILEGES;
Revoke grants:
mysql> REVOKE ALL PRIVILEGES ON db_name.* FROM 'username'@'localhost';
mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'localhost';
List tables:
mysql> show tables;
List databases:
mysql> show databases;
No comments:
Post a Comment