MySQL for mac usage record and mysqlformac record

Source: Internet
Author: User

MySQL for mac usage record and mysqlformac record

1. log on

Open the terminal and enter/usr/local/mysql/bin/mysql-u root-p.

Enter mysql for the first time. The password is blank. When the mysql> prompt appears, it indicates that you have entered mysql. Type exit to exit mysql.

 

Ii. change the password of the Mysqlroot user

Change the mysql root User password and enter/usr/local/mysql/bin/mysqladmin-u root password on the terminal.

Set a new password and enter/usr/local/mysql/bin/mysql-u root-p again to log on:

 

3. Create a user

Log on to mysql as root:

Create a user, type insert into mysql. User (Host, user, Password) values ("localhost", "new User", password ("Password "));

Refresh the system permission table and type flush privileges;

In this way, a user named Lands and whose password is Lands is created. Try to log on with the new user password:

 

4. delete a user

Log on to the root account.

Delete a user and type delte from mysql. User WHERE user = "User Name ";

Refresh the permission table and type flush privileges;

 

5. change the password of a specified user

Log on to the root account.

Modify the password of the specified user, and enter update mysql. User set password = password ("new password") where user = "username" and Host = "localhost ";

Refresh the permission table and type flush privileges;

 

6. Create a database for the user

Log on to the root account. Create a database first: enter the name of the create database;

Then, add the database operation permissions to the user, and type grant all privileges on database name. * to username @ localhost identified by 'username ';

Refresh the permission table and type flush privileges;

If you only specify some permissions for the user, type grant select, update on database name. * to username @ localhost identified by 'username '; refresh the permission table,

Type flush privileges;

 

VII. Database Operations

Log on to the root account.

1. create a new database and enter the name of the create database;

2. Open a database and enter the name of the use Database;

3. display all data tables in the database, and type show tables;

4. create a database table and enter the name of the create table data table (Field 1 field type, Field 2 field type );

5. display the table structure. Type The Name Of The describe data table;

 

6. insert data into the table, and type "insert into data table name value" ("field value 1", "field value 2 ");

7. update the data in the table. Type "set field 1 = field value 1" in the name of the update data table, where filtering condition;

8. delete the table data, and type the where query condition for the delete from table name;

9. Clear the table data and type the name of the delete from table;

10. delete a data table. type the name of the drop table data table;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.