Mysql for mac usage summary, mysqlformac Summary
1. log on
Log on to the terminal using the absolute path:/usr/local/mysql/bin/mysql-u root-p.
Change the password of the mysql root Account. Enter the command:/usr/local/mysql/bin/mysqladmin-u root password.
2. Create a user
@> Mysql-u root-p @> Password
Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "changyou", password ("changyou"); refresh the system permission table mysql> flush privileges; in this way, a user named changyou and whose password is changyou is created. Then log on. Mysql> exit; @> mysql-u changyou-p @> enter the password mysql> logon successful
@> Mysql-u root-p @> password mysql> delete from user WHERE User = "phplamp" and Host = "localhost"; mysql> flush privileges; // Delete the user's database mysql> drop database phplampDB;
- Modify the password of a specified user.
@> Mysql-u root-p @> password mysql> update mysql. user set password = password ('new password') where User = "phplamp" and Host = "localhost"; mysql> flush privileges;
3. user authorization
1.
Grant all privileges on.To 'changyou' @ '%' with grant option;
Grant all privileges on.To 'changyou' @ '%' identified by 'changyou ';
Flush privileges;
2.
Grant all privileges on.To 'user' @ 'localhost' with grant option;
Grant all privileges on.To 'user' @ 'localhost' identified by '000000 ′;
Flush privileges;
4. Create a database for the user
Log on to MYSQL (with ROOT permission ). Log on as ROOT. @> mysql-u root-p @> the password first creates a database (changyouDB) mysql> create database changyouDB for the user, and authorizes the changyou user to have all permissions for the changyouDB database. Grant all privileges on changyouDB. * to changyou @ localhost identified by 'changyou'; refresh the system permission table mysql> flush privileges; mysql> if you want to specify some permissions for other operations to a user, you can write as follows: mysql> grant select, update on changyouDB. * to changyou @ localhost identified by 'changyou'; // refresh the system permission table. Mysql> flush privileges;
V. Database Operations