1. Install dev on the MySQL official website. mysql. comdownloadsmysql, download mysql can install dmg version such as: MacOSXver.10.7 (x86, 64-bit), DMGArchive downloaded file: mysql-5.6.10-osx10.7-x86_64.dmg1. click 2 in the installation package. click Install and install, and then set the system preference.
1. Install MySQL at http://dev.mysql.com/downloads/mysql/. download mysqlto install the dmgversion, for example, Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive downloaded file: mysql-5.6.10-osx10.7-x86_64.dmg 1. click 2 in the installation package. click Install and install, and then set the system preference.
I. Installation
Go to the MySQL official website at http://dev.mysql.com/downloads/mysql/, and download mysqlinstallable dmgversion
For example, Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive
The downloaded file is: mysql-5.6.10-osx10.7-x86_64.dmg
1. Click
2. Click to install
After the installation, the system preference settings, such as the following, will appear:
3. Click this icon to pop up the dialog box.
Click Start MySQL Server to Start mysql
2. Open the terminal and define the mysql alias
Enter the alias command
alias mysql=/usr/local/mysql/bin/mysql
Press enter and enter
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
3. Set the password of the mysql root Account
Mysqladmin-u root password initial password
2. If you need to modify the password, run the following command:
Mysqladmin-u root-p password latest password
Enter the password. Enter the old password and press Enter.
4. Connect to the database
mysql -u root -p
Then, enter the password and the initial password set in step 3.
2. If you log on to the mysql database on the remote host
Mysql-h host address-u user name-p User Password
5. Perform common mysql database operations
Note: The following operations are all performed. After connecting to the database, you can enter the mysql environment. The commands executed later must contain a semicolon (;).
First, use root permission to connect to mysql
mysql -u root -p
Then, enter the root password.
1. Add new users
The format is as follows:
Grant operation permission on database. * to username @ login host address identified by 'Password ';
Grant a user (with the user's login password) on a host the permission to perform certain operations on a database.
(1) For example, on any host ("%"), the user (username: test1, password: adc) has the permission to perform any operation on all databases (very dangerous)
grant all privileges on *.* to test1@"%" identified by "abc";
All privileges indicates the query, insert, modify, and delete permissions: select, insert, update, and delete.
The preceding commands are equivalent:
grant select,insert,update,delete on *.* to test1@"%" identified by "abc";
Then refresh the permission
flush privileges;
(2) For example, authorize the user on the local host to operate on the database
Create a database (for example, openfire)
create database openfire;
Grant the operation permission of the local host user (username: test2, password: 123) to access the database (Database Name: openfire)
grant all privileges on openfire.* to test2@localhost identified by "123";
flush privileges;
Then, you can use a new user to access the openfire database.
2. Update the password of the specified account (username: test1, new password: 1234)
update mysql.user set password=password('1234') where User="test1" and Host="localhost";
3. delete a user
Use the mysql database first
use mysql;
Delete a local user (test7) from the user table in the mysql database)
delete from user where User="test7" and Host="localhost";
4. Display commands
(1) display the list of all databases
show databases;
Only two databases are initialized, mysql and test.
Note: MYSQL system information is stored in the mysql database. For example, you can use this database to modify the password and add new users.
(2) open a database (such as the database: openfire)
use openfire;
(3) display all tables in this database
show tables;
(4) display the structure of a table (table1)
describe table1;
(5) database creation
Create database name;
(6) create a table
Use Database Name; create table Name (field setting list );
(7) delete a database
Drop database name;
(8) delete a table
Drop table name;
(9) clear records in the table
Delete from table name;
(10) display records in the table
Select * from table name;
6. log out of mysql
exit
7. Start and Stop MySQL
Start
/usr/local/mysql/share/mysql.server start
Stop
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
Enter the root password
Http://www.cnblogs.com/macro-cheng/archive/2011/10/25/mysql-001.html
1. Download MySQL
Visit the MySQL official website http://www.mysql.com/downloads/ and then on the page will see "MySQL Community Server" below a "download" click.
Go to the MySQL download interface (http://www.mysql.com/downloads/mysql/), if you are using Mac OS access, then it will be selected for you by default Mac OS X platform, the following lists the MySQL versions that can be used on Mac OS. If you are using another Platform, Select the "Select Platform" option from the drop-down list.
There are many MySQL versions on Mac OS, including platform-based, such as 10.5/second and. dmg. Here I choose. dmg. Click download on the right to download.
Next, you will be redirected to another interface, which prompts you to register it. You can directly select "No thanks, just take me to downloads!" at the bottom !", Then, the download page is displayed. This page lists many servers for download. You can select a server to download.
2. Install MySQL
Open the MySQL installation package:
Install
Mysql-5.5.16-osx10.6-x86_64.pkg: This is the main MySql package;
MySQL_StartupItem.pkg: MySql startup item;
MySQL. prefPane: After the installation is complete, it will appear in the system preference settings, which are MySQL preference settings, which are mainly used to start the MySQL service.
3. Download and install MySQL Workbench (GUI Tool)
3.1 download MySQL Workbench
Access http://www.mysql.com/downloads/ has a MySQL Workbench (GUI Tool) item below, click DOWNLOAD under it to enter the DOWNLOAD interface:
Then select the version and then select the server for download. There seems to be only one version:
3.2 install MySQL Workbench
After the download is complete, the installation is very simple. You can double-click it to install it. After the installation is complete, we can see the MySQL Workbench. app program in the "application. Double-click to open:
MySql Workbench has been installed.
After the installation is complete, we will talk about connecting MySQL Workbench to the MySQL database and then managing the database.
3.3 create a new connection
The main interface of MySQL Workbench includes three modules: SQL Development, Data Modeling, and Server Administration. Under SQL Development, a "New Connection" dialog box is displayed after you click "New Connection". After Entering the Connection Name, click "OK. You can complete a connection to the local database.
After the connection is completed, the connection just created appears on the main interface, for example:
Double-click the Connection name or select a Connection and click "Open Connection to Start Querying" to go to the database operation interface:
All these prerequisites are that the database service must be enabled.
3.4 manage the database access password
The default password of MySQL is root/root. Normally, we can use MySQL Workbench to manage the database, however, when we access MySQL through jdbc in programming code, we will find that using this account is not good and cannot be accessed, because MySQL requires us to change the password, that is to say, the root password is the default password, that is, the weak password, which must be modified before it can be used in the code. Therefore, we need to manage the database access password.
Create a Server Instance
In the "Server Administration" module, after clicking "New Server Instance", a "Create New Server Instance Profile" dialog box is displayed, which can be completed step by step, generally, the local database is OK directly with the default settings. After that, we can see the created instance on the far right of the main interface of Workbench.
Double-click the manager to open it. The password is required here. The root account is the one that has not been changed yet. Then there is a "SECURITY" sub-menu item "Users and Privileges" under the left-side menu bar. The following interface is displayed when you select this item:
In the right-side pane, there is a list of User Accounts. Select the account in which you want to change the password and change the password on the right.