MySQL for Mac usage record

Source: Internet
Author: User

First, Login

Open terminal, enter/usr/local/mysql/bin/mysql-u root-p

The first time you enter MySQL, the password is empty. When the mysql> prompt appears, you have entered MySQL. Type exit to exit MySQL.

Second, change the mysqlroot user password

Change MySQL root user password, enter/usr/local/mysql/bin/mysqladmin-u root password new password in terminal

To set a new password, enter/usr/local/mysql/bin/mysql-u root-p login again:

Third, create the user

Log in to MySQL as root:

Create a user, type insert into Mysql.user (Host,user,password) VALUES ("localhost", "New User", Password ("password"));

Refresh the System Permissions table and type flush privileges;

This creates a user named lands with a password of lands. Try to log in with a new user password:

Iv. Deleting users

Log in to the root account.

Delete user, type delte from Mysql.user WHERE user= "username";

Refresh the Permissions table, type flush privileges;

V. Modify the specified user password

Log in to the root account.

Modify the specified user password, type update mysql.user set Password=password ("New password") where user= "username" and host= "localhost";

Refresh the Permissions table, type flush privileges;

Vi. creating a database for users

Log in to the root account. First create a database: type create database name;

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

Refresh the Permissions table, type flush privileges;

If you specify only partial permissions to the user, type the grant Select,update on database name. * To user name @localhost identified by ' username '; Refresh the Permissions table,

Type flush privileges;

VII. Operational Database

Log in to the root account.

1, create a new database, type create database name;

2. Open a database and type the name of the use database;

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

4. Create a database table, type CREATE table data table name (Field 1 field type, Field 2 field type);

5, display the structure of the table, type describe data table name;

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

7. Update the data in the table, type the update data table name set field 1 = field value 1 where filter condition;

8. Delete data from table, type delete from data table name where query condition;

9. Clear the table data, type the delete from data table name;

10, delete the data table, type the drop table data table name;

MySQL for Mac usage record

Related Article

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.