Uninstall and install Mysql under MacPro

Source: Internet
Author: User
Uninstall and install Mysql in MacPro: OSX10.11.5 yesterday, in order to modify my Mysql password, I found a bunch of tutorials and tried various things in unknown situations. Finally, I took off my mysql, on the twists and turns of the mysql reinstallation path. I. uninstall Mysql on Mac: for example, use brew to install brewuninstallmysql or brew.

Uninstall and install Mysql in Mac Pro: OS x 10.11.5 yesterday I found a bunch of tutorials to change my Mysql password, finally, I took my mysql off and embarked on the twists and turns mysql reinstallation path. I. uninstall Mysql on Mac: for example, use brew to install: brew uninstall mysql or brew

Uninstall and install Mysql under Mac Pro

System version:OS X 10.11.5

Yesterday, in order to modify my Mysql password, I found a bunch of tutorials and tried various things in an unknown situation. Finally, I took off my mysql and embarked on a tortuous mysql reinstallation path.

I. uninstall Mysql on Mac:

For example, use brew to install:brew uninstall mysqlOrbrew remove mysql

But I am a little afraid that some things have not been uninstalled, which will completely affect the next installation (this is my first reinstallation ??) The following is a completeManually uninstall:

  • Sudo rm/usr/local/mysql
  • Sudo rm-rf/usr/local/mysql *
  • Sudo rm-rf/Library/StartupItems/MySQLCOM
  • Sudo rm-rf/Library/PreferencePanes/My *
  • Rm-rf ~ /Library/PreferencePanes/My *
  • Sudo rm-rf/Library/Receipts/mysql *
  • Sudo rm-rf/Library/Receipts/MySQL *
  • Sudo rm-rf/var/db/receipts/com. mysql .*

Reference: How do you uninstall MySQL from Mac OS X?

In fact, different installation methods have different storage locations for some things. after deletion, check whether some files have been deleted. if not, delete them:

  • /Usr/local/mysql file in Cellar
  • Mysql file in/usr/local/var
  • Mysql. sock, mysql. sock. lock, my. cnf file in/tmp
  • Both the pid file and the err file must be deleted in/usr/local/var/mysql.
  • The brew installation package can also be deleted at/usr/local/Library/Cache/Homebrew.
  • Runbrew cleanup
II. functions of various files

During the installation and uninstallation process, I am not very familiar with the functions of many files. as a result, I will only find the answer to any problem, sometimes, when the answer is useful, it will be very difficult to find the answer, so I want to know what the roles of some files are.

The most common problems during installation:

ERROR!The server quit without updating PID file (/usr/local/var/mysql/***MacBook-Pro.local.pid)

(1) Pid file:

Record = Process ID of the current Mysql Process =. If no pid file is specified, the default pid file name isHost name. local. pidIn the default MySQL data directory. Passmysqld_safeWhen MySQL is started,mysqld_safeThe pid file is checked. if the pid file does not exist, no processing is performed. if the file exists and the pid is occupied, an error is returned.A mysqld process already existsIf the file exists but the pid is not occupied, delete the pid file.

After mysqld is startedcreate_pid_fileFunction to create a pid file.getpid()Obtain the pid of the current process and write the pid to the pid file.

Thereforemysqld_safeAt startup, the MySQL pid file is used to prevent the same database from being started multiple times when the data file is the same but the port is different.

? /Ll/usr/local/var/mysql/SarahMacBook-Pro.local.pid-rw-r ----- 1 sarah admin 6B 5 19/usr/local/var/mysql/SarahMacBook-Pro.local.pid? /Ps-ef | grep mysql | grep-v grep 501 65673 1 0 4 05 PM ?? 0: 00. 02/bin/sh/usr/local/opt/mysql/bin/mysqld_safe -- bind-address = 127.0.0.1 -- datadir =/usr/local/var/mysql 501 65767 65673 0 4 05 afternoon ?? 0: 52. 44/usr/local/Cellar/mysql/5.7.12/bin/mysqld -- basedir =/usr/local/Cellar/mysql/5.7.12 -- datadir =/usr/local/var/mysql -- plugin-dir =/usr/local/Cellar/mysql/5.7.12/lib/plugin -- bind-address = 127.0.0.1 -- log-error =/usr/local/var/mysql/SarahMacBook-Pro.local.err -- pid-files =/usr/local/var/mysql/SarahMacBook-Pro.local.pid? /Cat/usr/local/var/mysql/SarahMacBook-Pro.local.pid65767.

Reference: What is the mysql pid file? Wen Guobing source Zhihu

For solutions to The above problems, see MySql server startup error 'The server quit without updating PID file' or MySQL prompt: The server quit without updating PID file problem solution or

View the ownership of some files:ls -laF /usr/local/var/mysql/If it is not mysql or your hostname, modify it.Sudo chown-R mysql [or hostname]/usr/local/var/mysql/

Open the. err file with the same pid name in the same directory to view the error log. view the error and follow the error prompt to find the cause.

(2) error logs:

MySQL has four types of logs: Error Log, General Query Log, Binary Log, and Slow Query Log.

  1. The ERROR log records the MySQL running process ERROR, WARNING, NOTE, and other information. you can view the ERROR log if a system ERROR occurs or a certain record has a problem. Stored in the same directory as the pid file. the default value isHost name. local. errOr query in Mysqlmysql> show variables like ‘log_error’;You can/etc/my.cnfAdd--log-error[=file_name]To enable the mysql error log.
  2. The daily running logs record each request data in the MySQL operation. In/etc/my.cnfAddgeneral-log-file[=file_name]
  3. Binary logs contain some events that describe database changes, such as table creation and data changes. They also include some potential changes, which are mainly used for backup recovery and rollback.
  4. Slow query logs for MySQL Performance Optimization.

For other settings, see MySQL log analysis.

(3)/etc/my. cnf file:

The my. cnf file is the Mysql configuration file. When Mysqld starts the service, it reads the configuration file in a certain order by default, and follows the principle that the configuration is better than the configuration. the configuration read later overwrites the configuration read earlier, mysql will take the last configuration file read as the standard.

View the mysql read sequence:

?  ~ mysqld --help --verbose | grep -A 10 'Usage:'Usage: mysqld [OPTIONS]Default options are read from the following files in the given order:/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnfThe following groups are read: mysqld server mysqld-5.7The following options may be given as the first argument:--print-defaults        Print the program argument list and exit.--no-defaults           Don't read default options from any option file,                        except for login file.--defaults-file=#       Only read default options from the given file #.--defaults-extra-file=# Read this file after the global files are read.

If the file does not exist:

After several installation methods have been tried, the file is not found in these folders, and the default configuration file for mysql installation is found in support-files under the installation directory, copy it, modify some of the configurations, and then restart.

sudo cp /usr/local/Cellar/mysql/5.7.12/support-files/my-default.cnf /etc/my.cnf

Then you can easily start and stop mysql (this script actually calls the mysqld_safe script, and thenmysqld_safeThen call the binary file mysqld ):/etc/init.d/mysql start

It may not work after setting the/etc/my. cnf file to run. check whether the files in the read sequence exist. if so, delete the files and restart them. {

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.