Install [cpp] for MySQL for mac 1. Install mysql [cpp] 1. mysql http://dev.mysql.com/downloads/mysql/ My machine is mac 10.8; so use the mysql-5.6.10-osx10.7-x86_64.dmg installation package; 2. The installation package is located in the hard disk image (. dmg) file, you must first double-click the icon in the search to install the file. Images should be installed and displayed. Note: Before continuing the installation, you must use the MySQL Manager application (on the Mac OS X Server) or use the mysqladmin shutdown command line to close all MySQL Server instances. Install Mac OS X PKG of MySQL to/usr/local/mysql-VERSION, and install a symbolic connection,/usr/local/mysql, pointing to a new location. If the/usr/local/mysql directory exists, first change it to/usr/local/mysql. bak. After installation, the installer runs mysql_install_db to create an authorization table in the MySQL database. The installation layout is similar to that of the tar binary distribution. All MySQL binary codes are in the/usr/local/mysql/bin directory. By default, the MySQL socket file is created as/tmp/mysql. sock. There are two ways to install MYSQL in MAC, one is compressed package and the other is the. dmg File Installation Package. First introduce the installation method of compressed package: $ sudo mv mysql-5.1.45-osx10.6-x86_64/usr/local/mysql $ cd/usr/local $ sudo chown-R mysql: mysql $ cd mysql $ sudo scripts/mysql_install_db -- user = mysql $ sudo chown-R root. $ sudo chown-R mysql data and then use $ sudo for cd bin. /mysql_secure_installation to change the root password. The default value is null, which is obviously not safe. Configure the password as prompted, because the development environment does not have to be so restrictive. $ Sudo. /mysqld_safe to start mysql $ sudo. /mysql-u root-p enter the root password just set to log on to mysql $ sudo. /mysqld_safe stop to stop installation in the form of mysql installation package file: first, go http://www.mysql.com/downloads/mysql Download the mysql-5.6.10-osx10.7-x86_64.dmg and double-click the file to install the two installation packages in the image. A. mysql-5.6.10-osx10.7-x86_64.dmg (mysql Standard Edition installation) B. mySQLStartupItem. pkg (mysql startup project) can automatically run the mysql service when your computer starts the system. It is installed in/Library/StartupItems/MySQL/. If you do not want to run the mysql service when the system starts, do not install. If you do not want to use it after installation, delete the/Library/StartupItems/MySQL/directory. Start mysql Service 1. If you have installed MySQLStartupItem. pkg, restart your computer. 2. If you have installed MySQLStartupItem. pkg or do not want to start the computer, run: Application-utility-terminal, enter the command in the terminal: sudo/Library/StartupItems/MySQLCOM start, enter your system administrator password. Close the mysql service terminal and enter the command: sudo/Library/StartupItems/MySQLCOM stop, and then enter your system administrator password. You can also go to system preference settings-other-MySQL to start and stop the MySQL service. In the terminal for changing the password of the mysql root Account, enter the command:/usr/local/mysql/bin/mysqladmin-u root password. You can use this command to change your password at any time. Terminal login mysql terminal login mysql Method 1: absolute path terminal input command:/usr/local/mysql/bin/mysql-u root-p prompt: enter your new password Method 2: (recommended) enter the relative PATH command in the terminal: Check whether there is any required PATH in the PATH: Enter the command in the terminal: echo $ PATH does not exist, continue to add the required PATH: PATH = "$ PATH":/usr/local/mysql/bin. Then, enter the command mysql-u root-p. create a user to assign permissions [cpp] grant all privileges on *. * to 'user' @ 'localhost' with grant option grant all privileges on *. * to 'user' @ 'localhost' identified by '000000'; flush privileges; 1. Create a user. Log on to MYSQL @> mysql-u root-p @> password creation user mysql> insert into mysql. user (Host, User, Password) values ("localhost", "phplamp", password ("1234"); refresh the system permission table mysql> flush privileges; in this way, a user named: phplamp password: 1234 is created. Then log on. Mysql> exit; @> mysql-u phplamp-p @> enter the password mysql> login successful 2. Authorize the user. Log on to MYSQL (with ROOT permission ). I log on as ROOT. @> mysql-u root-p @> the password first creates a database for the user (phplampDB) mysql> create database phplampDB; Authorizes the phplamp user to have all permissions for the phplamp database.> Grant all privileges on phplampDB. * to phplamp @ localhost identified by '000000'; refresh the system permission table mysql> flush privileges; mysql> if you want to specify some permissions for other operations to a user, write as follows: mysql> grant select, update on phplampDB. * to phplamp @ localhost identified by '000000'; // refresh the system permission table. Mysql> flush privileges; 3. delete a user. @> 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; 4. 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;