Install MySQL on Mac

Source: Internet
Author: User
Tags mysql version

I didn't think it would take me two or three days to configure my MacBook for the PHP environment. Seemingly online looking for a lot of tutorials, but mostly a few years ago, and recently six months ago, the most important card in the database this, MySQL version is different, the installation process is not the same. Fortunately, it's finally done. Just record it here for a rainy future.

1: Open Apache

Terminal operation

sudo apachectl start

Open Apache;

This time enter

sudo apachectl-v

You should see a large list of Apache-related configuration information.

At this point, open the Safari browser address bar and enter "http://localhost" to see the content "It works!" The page. proves that Apache has been turned on.

The root directory of Apache is located under "/library (Resource Library)/webserver/documents/", after which the PHP program is placed in the background of the project.

Apache installation directory Open method: Doker Right click on the Finder = "Go to Folder" = "Enter"/etc "

2: Configure related files

Go to the Apache installation directory, open the Apache2 folder = "httpd.conf file, find" #LoadModule php5_module libexec/apache2/libphp5.so ", remove the previous # number, save

Then Apache install directory, open apache2 folder = "Open Extra folder =" httpd-vhosts.conf file, will file

<virtualhost *: the>ServerAdmin [email protected]-host.example.com DocumentRoot"/usr/docs/dummy-host.example.com"ServerName Dummy-host.example.com errorlog"/private/var/log/apache2/dummy-host.example.com-error_log"Customlog"/private/var/log/apache2/dummy-host.example.com-access_log"Common</VirtualHost> <virtualhost *: the>ServerAdmin [email protected]-host2.example.com DocumentRoot"/usr/docs/dummy-host2.example.com"ServerName Dummy-host2.example.com errorlog"/private/var/log/apache2/dummy-host2.example.com-error_log"Customlog"/private/var/log/apache2/dummy-host2.example.com-access_log"Common</VirtualHost>

Each line is commented out with # and the following code is added at the end:

<virtualhost *: the>DocumentRoot"/library/webserver/documents"ServerName localhost errorlog"/private/var/log/apache2/localhost-error_log"Customlog"/private/var/log/apache2/localhost-access_log"Common</VirtualHost> <virtualhost *: the>DocumentRoot"/users/snandy/work"ServerName mysites errorlog"/private/var/log/apache2/sites-error_log"Customlog"/private/var/log/apache2/sites-access_log"Common<directory/>Options Indexes followsymlinks multiviews allowoverride None Order deny,allow allow from All</Directory> </VirtualHost>

3: Restart Apache, terminal input

sudo apachectl restart

4-1: Install the database (I've been stuck here for a long time)

First you have to have a file:

http://dev.mysql.com/downloads/mysql/

Open the URL and download the DMG

After downloading, double click Install, no brain next step.

Attention! Before the installation is complete there will be a hint, the system will also have a warning tone, note that this time out of the pop-up window do not have a brain point to determine, because the new version of MySQL will default to generate a random password, on the pop-up window, the password copy down, or it is very troublesome. Like me, I put them all in the Notepad, probably the information we need to save is this:

to -01t13:1:fornllw+a_3& P (H This in the MySQL reference manual

The bold part is the code.

4-2: Modify Database Configuration

At this point into the system preferences, you can see the bottom of a MySQL, the database has been installed successfully, click on the icon, there is a Start button, as the name implies, now we want to start MySQL, the database started.

Then, at the command line, enter:

CD/+W Bashrcsudo vi bashrc
Alias mysql='/usr/local/mysql/bin/mysql'alias mysqladmin='/usr/ Local/mysql/bin/mysqladmin'

Then restart the database.

4-3: Enter the database, change the password

Terminal input

Mysql-uroot-p

Will prompt

At this time, the installation will be randomly generated password input, long password, copy and paste, enter

If it goes well, this will prompt a lot of welcome information, in short you see welcome, even if it is OK, then only need to change the password, you can do it:

At this point, enter the command:

show databases;

Will prompt you to change the password and the like in English:

1820 using  this statement.

Then enter:

SET PASSWORD = PASSWORD ('123456');

Set the password to 123456, of course, you can also change the password you want. This will show

0 rows affected (0.03

At this point, the evil Mac PHP environment is finished. Finally can happily write the code ~ Imagine still a little excited ~

Install MySQL on Mac

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.