MySQL for Mac installation and basic operations, mysqlmac
1. Install mysql
1. mysqlhttp: // 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 double-click the icon in the search box to install the package. 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 in the form of a compressed package:
$ sudo mv MySQL-5.1.45-osx10.6-x86_64 /usr/local/mysql
$ cd /usr/local
$ sudo chown -R mysql:mysql mysql
$ cd mysql
$ sudo scripts/mysql_install_db --user=mysql
$ sudo chown -R root .
$ sudo chown -R mysql data
Then use cd bin
$ sudo ./mysql_secure_installation
To modify 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 you just set to log on to mysql.
$ sudo ./mysqld_safe stop
Stop mysql
Installation Method in the form of installation package file:
First.
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.
Disable mysql Service
Enter the command sudo/Library/StartupItems/MySQLCOM stop in the terminal, and enter your system administrator password.
You can also go to system preference settings-other-MySQL to start and stop the MySQL service.
Change the mysql root Account Password
Enter the command in the terminal:/usr/local/mysql/bin/mysqladmin-u root password New password
You can use this command to change your password at any time.
Terminal login mysql
Terminal LogonMysql
Method 1: absolute path
Enter the command in the terminal:/usr/local/mysql/bin/mysql-u root-p
Tip: enter your new password.
Method 2: (recommended) Relative Path
Enter the following command in the terminal:
Check whether the required path is in the path:
Enter the command echo $ PATH in the terminal.
No, continue
Add the required PATH: PATH = "$ PATH":/usr/local/mysql/bin
Later
Enter the mysql-u root-p command in the terminal.
2. Create a user to assign Permissions
Grant all privileges on *. * to 'user' @ 'localhost' with grant option
Grant all privileges on *. * to 'user' @ 'localhost' identified by '123 ′;
Flush privileges;
1. Create a user.
Log on to MYSQL
@> Mysql-u root-p
@> Password
Create user
Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "phplamp", password ("1234 "));
Refresh system permission list
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> logon successful
2. Authorize the user.
Log on to MYSQL (with ROOT permission ). I log on as ROOT.
@> Mysql-u root-p
@> Password
First, create a database (phplampDB) for the user)
Mysql> create database phplampDB;
Authorize the phplamp user to have all the permissions of the phplamp database.
> Grant all privileges on phplampDB. * to phplamp @ localhost identified by '123 ';
Refresh system permission list
Mysql> flush privileges;
Mysql> other operations
If you want to assign some permissions to a user, you can write as follows:
Mysql> grant select, update on phplampDB. * to phplamp @ localhost identified by '123 ';
// 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 the 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;
Author's Public Account: Human Machine Learning
I have been sharing machine learning practices for a long time. Thank you for your attention!