


Configure PHP+MySql environment under Mac OS, osphp+mysql_PHP tutorial
Configure PHP+MySql environment under Mac OS, osphp+mysql
Since mantis recently needs to be deployed for bug tracking, the process is recorded here.
Since the PHP apache environment comes with Mac OS, there is no need to install the installation package elsewhere, just a simple configuration.
First open the terminal and enter the command:
sudo vim /etc/apache2/httpd.conf
There is a line like this
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the # sign in front.
Then open Sharing in System Preferences and check web sharing, as shown below
Restart apache, the command is as follows:
sudo apachectl restart
In this way, you can enter http://localhost/ in the browser, and if
appearsIt works!
Description of successfully configuring the php environment
Let’s configure the MySql environment.
First download the dmg installation package of MySql. The download address is: http://dev.mysql.com/downloads/mysql/
Open the dmg file. There are three installation items in it. I installed all three here. After MySQLStartupItem.pkg is installed, mysql will start automatically when the system starts. MySQL.prefPane indicates that the mysql option can be seen in the system preferences. , and the other one is the mysql installation item.
In this way, the installation is successful. Open mysql in the system preferences and enable the service. After installation, the default username is root and the password is empty. For security, we set a password.
Open the terminal. If you enter mysql and you are prompted that there is no such command, you need to configure the environment variables of the mysql bin directory. The directory is, /usr/local/mysql/bin/, add it to the PATH variable. Here I introduce another method,
Enter
in the terminalsudo vim /etc/bashrc
Then add
in it#mysql
alias mysql='/usr/local/mysql/bin/mysql'
alias mysqladmin='/usr/local/mysql/bin/mysqladmin'
In this way, if you enter mysql in the terminal, you will have this command. In fact, it is somewhat similar to the macro definition in our C/C++, and the alias is used instead.
Then we change the root password, the command is as follows:
mysqladmin -uroot password 12345
This will change the root password to 12345.
To manage Mysql, if it is troublesome to use the command line, the open source phpMyAdmin adopts C/S mode for easy management. Then we install phpMyAdmin. It is developed by php, and the download address is: http://www.phpmyadmin.net/home_page/downloads.php
Put the downloaded unzipped file in the /Library/WebServer/Documents/ directory. The complete directory is: /Library/WebServer/Documents/phpmyadmin/, then enter this directory with the command line,
Enter the command:
cp config.sample.inc.php config.inc.php
vim config.inc.php
Make changes as follows:
$cfg['blowfish_secret'] = '';//For cookie encryption, any long string
$cfg['Servers'][$i]['host'] = '127.0.0.1';//MySQL daemon does IP binding
Now you can enter the URL in the browser: http://localhost/phpmyadmin/
Server name: root
The password is the password you set.
You can log in to the mysql management interface.
Okay, the above is all about configuring the PHP+MYSQL environment in MAC OS. I hope you guys like it.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Methods for configuring character sets and collations in MySQL include: 1. Setting the character sets and collations at the server level: SETNAMES'utf8'; SETCHARACTERSETutf8; SETCOLLATION_CONNECTION='utf8_general_ci'; 2. Create a database that uses specific character sets and collations: CREATEDATABASEexample_dbCHARACTERSETutf8COLLATEutf8_general_ci; 3. Specify character sets and collations when creating a table: CREATETABLEexample_table(idINT

Installing MySQL on macOS can be achieved through the following steps: 1. Install Homebrew, using the command /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". 2. Update Homebrew and use brewupdate. 3. Install MySQL and use brewinstallmysql. 4. Start MySQL service and use brewservicesstartmysql. After installation, you can use mysql-u

Use the EXPLAIN command to analyze the execution plan of MySQL queries. 1. The EXPLAIN command displays the execution plan of the query to help find performance bottlenecks. 2. The execution plan includes fields such as id, select_type, table, type, possible_keys, key, key_len, ref, rows and Extra. 3. According to the execution plan, you can optimize queries by adding indexes, avoiding full table scans, optimizing JOIN operations, and using overlay indexes.
