Install MySQL under Mac Pro Uninstall

Source: Internet
Author: User
Tags mysql version symlink types of tables


Install MySQL under Mac Pro Uninstall


System version:OS X 10.11.5



Yesterday in order to modify my MySQL password, find a bunch of tutorials in the case of the unknown so all kinds of disorderly try, finally put my MySQL play off, embarked on the twists and turns of MySQL re-install the road.


One, Mac about MySQL uninstall:


if using a brew installation :brew uninstall mysqlorbrew remove mysql



But I'm a little afraid of something. No uninstall completely affects the next installation (this is the first time I reinstall?? The following is a complete manual 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 does uninstall MySQL from Mac OS X?



In fact, different installation methods some things storage location is not the same, delete check some of the files are deleted, if not delete:


    • MySQL file in/usr/local/cellar
    • MySQL file in/usr/local/var
    • /tmp Mysql.sock, Mysql.sock.lock, my.cnf file
    • Both the PID file and the Err file are in the/usr/local/var/mysql to make sure it is deleted.
    • The brew installation package is stored in/usr/local/library/cache/homebrew and can be deleted as well.
    • Performbrew cleanup
Ii. the role of various documents


This uninstall installation process, the deepest feeling or the role of a lot of files are not very understanding, resulting in what problems will only follow that question to find the answer, sometimes found the answer has a role in finding the answer will be very pit, so want to know what the role of some of those files



The most common problems during the installation process are:



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


(a) PID file:

Record = = Process id== of the current MySQL process. When the PID file is not specified, the PID file is named by default主机名.local.pid, storing the path in the default MySQL data directory. Bymysqld_safestarting MySQL, themysqld_safepid file is checked, if the PID file does not exist, does not do processing, if the file exists, and the PID is occupied errorA mysqld process already exists, if the file exists, but the PID is not occupied, then delete the PID file.

Mysqld after startup, it willcreate_pid_filecreate a new PID file through the function,getpid()obtain the current process PID and write the PID to the PID file

Thus, bymysqld_safestarting, the function of the MySQL PID file is 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 17:55 /usr/local/var/mysql/SarahMacBook-Pro.local.pid
? / ps -ef | grep mysql | grep -v grep
   501 65673 1 0 Thursday 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 Thursday 05 PM ?? 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-file = / usr / local / var / mysql / SarahMacBook-Pro.local.pid
? / cat /usr/local/var/mysql/SarahMacBook-Pro.local.pid
65767 


Reference: What is the MySQL PID file used for? Wen the source of the soldiers know



The workaround for the above problem can be consulted: MySQL server startup error ' the server quit without updating PID file ' or MySQL hint: the server quit without Updating PID file Problem Solving method or



View some of the files ownership:ls -laF /usr/local/var/mysql/non-mysql or my hostname is modifiedsudo chown -R mysql[或者hostname] /usr/local/var/mysql/



Open the. err file with the same name as the PID in the same directory to view the error log view error and follow the error to find the reason


(b), error log:


MySQL has four types of logs: Error log, General query log, Binary log, and Slow query log.


    1. Error log, log information such as MySQL running process error,warning,note, system error or a record problem can view the error log. stored in the same directory as the PID file, the default is主机名.local.error in MySQL querymysql> show variables like ‘log_error’;can be added in the/etc/my.cnf--log-error[=file_name]option to open the MySQL error log
    2. Daily run logs, recording each request data in MySQL run. In the/etc/my.cnfaddgeneral-log-file[=file_name]
    3. The binary log contains events that describe changes to the database, such as build tables, data changes, and other potential changes that are used primarily for backup recovery, rollback, and so on.
    4. Slow query log for MySQL performance tuning.


Refer to the MySQL log analysis for the rest of the viewing setup methods


(iii),/ETC/MY.CNF documents:


The my.cnf file is a MySQL configuration file. When Mysqld starts the service by default to read the configuration file in a certain order, followed by a configuration that is better than the configuration, after reading the configured to overwrite the previous read the principle of the configuration, then MySQL will read to the last configuration file prevail.



To view the MySQL read order:


?  ~ 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.cnf
The following groups are read: mysqld server mysqld-5.7
The 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:



Several installation methods have been tried, finally did not find the file in these folders, in the installation directory support-files found the installation of MySQL default configuration file, copy the past, and then modify some of the configuration, and then restart.



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



Then it is convenient to start stopping MySQL (this script actually calls the Mysqld_safe script and thenmysqld_safecalls the binary file mysqld):/etc/init.d/mysql start



It is possible that after setting the/etc/my.cnf file to run, it is not useful to look at the number of files after the reading order exists, and if so, delete and restart. {rpm: MySQL restart does not read/ETC/MY.CNF global configuration issues



Some parameters in the configuration file:


[mysql]
#prompt = "(\\ u: hostname: \ D) [\\ d]>"
This way when using mysql -uroot -p to connect to the mysql server, it will display
(root: hostname: Thu Feb 9 16:32:26 2012) [(none)]>

[client] The user tells the client tool mysql to connect to the database server using the port and socket file paths.

[mysql] Used to set the display information of client tools, such as set in my.cnf
port = 3306 // The port number when the mysql service runs, the default is 3306
password = your_password // mysql password
socket = /tmp/mysql.sock // socket file storage address
basedir = / usr / local / Cellar / mysql // root directory (installation directory)
datadir = / usr / local / var / mysql // data file directory
pid-file = / usr / local / var / mysql / your_pid_file_name // The address where the pid file is stored
log-error = / usr / local / var
r / mysql / your_err_file_name.log // err file storage address


Some other parameters can be viewed: MySQL configuration file my.cnf configuration and configuration parameters or MySQL configuration file my.cnf


(iv). Mysql.sock Documents:

There are two ways to connect MySQL:

  1. Tcp / ip
  2. Socket

When the server and client are on the same server (host) and are linked using localhost, the socket is used as a carrier of the communication protocol to connect, which is faster than TCP. That is, a MySQL connection established for Host name LocalHost, which is implemented via a socket file mysql.sock. Therefore, after the file is deleted, the user with localhost is not connected to the MySQL server.


if it appears:
Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘


    • Check to see if the file exists, or runmysql.server startor/usr/local/Cellar/mysql/5.7.12/support-file/mysql.start[你的安装目录里的support-file]see if the file exists
    • If/tmp/mysql.sock does not exist , a TCP/IP connection must be established, that is,127.0.0.1localhostto connect to the MySQL server instead of the-h parameter, such as:mysqladmin -h 127.0.0.1 -u root -p shutdown, to force a TCP/IP connection, Close the MySQL server and restart thelocalhostMySQL server for the hostname, and it will recreate a socket file. Turn from: The role of Mysql.sock
    • If /tmp/mysql.sock exists , check mysqld's running status tomysqld statusstart it, see if it is a permissions issuels -laF /usr/local/var/mysql/[installed DataDir] If non-host Modify permissionssudo chown -R mysql[或者hostname] /usr/local/var/mysql/and then restart MySQL , if it doesn't work, you can modify the/ETC/MY.CNF to see the socket path under [mysqld]socket=/usr/local/var/mysql/mysql.sockand restart MySQL


Mysql.sock.lock This file is used to detect if an installed



lsof-i:3306 View Portkill -9 PIDKill process


(v),mysqld,mysql_safe,mysql_client,mysql_server:


MySQL runs in the entire network environment using the client/server (Client/server) architecture. Its core program acts as a server role, and individual client programs connect to the server and make requests.



MySQL ServerOrmysqld, actually, it's a database server program. It manages access to the disk database and memory, is the MySQL core program, generates the management DB instance, the DB instance Task Scheduler thread, and provides the relevant interface for different client calls .MySQL ServerFor multi-threaded operations, it supports simultaneous access to multiple client connections. To better manage database content,MySQL Serverthe featured schema model supports a variety of storage engines to handle different types of tables (for example, it supports both transactional and non-transactional tables).



The word difference between server (server) and host (host) .Serverrefers to the software (MySQL server program mysqld). The server feature has its version number, which features include, what does not include, and so on. and host refers to the physical machine = = that the ==server program is running on. Host features include hardware configuration, operating system, network address, and so on. A host can have multiple MYSQLD instances running at the same time .



mysql-client: Tools for manipulating database instances, there are many clients operating MySQL instances, Mysql-client is just one of them, including Mysql,mysqldump,mysqlslap, these access, backup, stress testing tools. The client program is used to communicate with the server to modify database information that is managed by the server-side server.



mysql-serverAndmysql-clientis the DBMS's two tools for different operand objects. Server is a physical level of DBMS, which contains a series of mechanisms for storing data, and the integration of processing methods; The client is a user-oriented DBMS that provides a range of tools for users, including typically written SQL to be compiled within the server to manipulate physical data. Reference: MySQL client/server



mysqld_safeIt is recommended to start the MYSQLD Server in UNIX and NetWaremysqld_safe.mysqld_safeadded security features, such as restarting the server and writing run-time information to the error log file when an error occurs


Third, MySQL installation (i) using Brew installation
    • brew updateUpdate
    • brew install mysqlInstall MySQL, and note the information that appears during this installation
? ~ brew install mysql
/ *
  * Download and install, there is no password at the beginning of the installation, you need to run mysql_secure_installation to make some settings, and the password will be set in it
  * /
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.12.el_capitan.bot
################################################### ######################### 100.0%
==> Pouring mysql-5.7.12.el_capitan.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.12/bin/mysqld --initialize-insecure --user = sarah --b
==> Caveats
We ‘ve installed your MySQL database without a root password. To secure it run:
     mysql_secure_installation

To connect run:
     mysql -uroot

To have launchd start mysql now and restart at login:
   brew services start mysql
Or, if you do n‘t want / need a background service you can just run:
   mysql.server start


This is not a problem of the installation, the next executionmysql_secure_installationfollow the instructions in it to set up, set up can be directly run. Now, let's talk about the pit I met.



Problems with using brew to install MySQL:


    • After brew executes install MySQL, a series of installation information appears, an error appears, and the contents of the error are viewed:
==> Pouring mysql-5.7.12.el_capitan.bottle.tar.gz Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink lib/libmysqlclient.20.dylib
/usr/local/lib is not writable.

You can try again using:
  brew link mysql


Executionbrew link mysql:


? ~ brew link mysql
Linking /usr/local/Cellar/mysql/5.7.12 ...
Error: Could not symlink lib / libmysqlclient.20.dylib
/ usr / local / lib is not writable. // This folder is not writable


Modify Permissions:


?  ~ sudo chown -R $(whoami) /usr/local/lib/
Password:
?  ~ brew link mysql
Linking /usr/local/Cellar/mysql/5.7.12... 93 symlinks created


Problem solved, then just need to executemysql_secure_installationto set the password on the line


    • Find some homebrew installation MySQL method reference: OSX under the homebrew to install MySQL database or MySQL installation but it should be noted that the two installation tutorials in the initialization of the database may be due to the MySQL version of the update, should be changed to:unset TMPDIR–>mysqld -initialize --verbose --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmpIf you encounter other problems such as PID or mysql.sock during installation, refer to the problem solving methods described earlier.


(ii) use of. tar.gz



Install package


// Extract to the installation directory
/ usr / local / mysql
// Move the decompressed package to the installation directory
sudo mv mysql-5.7.12-osx10.11-x86_64 / usr / local / mysql
// Change the user and user group to which the mysql installation directory belongs (permissions)
cd / usr / local sudochown -R root: wheel mysql
// Complete some default initialization. After performing the following step, a temporary password will appear. Please save this password to modify the password.
sudo bin / mysqld --initialize --user = mysql
cd / usr / local / mysql
sudo support-files / mysql.server start //
sudo support-files / mysql.server restart // restart
sudo support-files / mysql.server stop // stop
sudo support-files / mysql.server status // Check MySQL running status
// Change password, enter the password given above
mysqladmin -u root -pold password password new password 


Reprinted from: Mac Installation mysql.tar.gz



(iii) DMG installation MySQL tried many times but failed all the time?? So I ended up struggling.



= = above content a lot of solutions and various documents to organize from the network, can find the source of the general is excerpted from the back link = =



Install MySQL under Mac Pro Uninstall


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.