Reprint: Installation and configuration of Php,mysql

Source: Internet
Author: User
Tags configuration php lowercase mysql client reserved unique id

This article transferred from: http://www.cnblogs.com/janas/archive/2012/08/27/2659240.html

First, install the configuration php

1. After downloading the PHP version zip package, unzip to the specified directory. : http://www.php.net/downloads.php
2. In Apache httpd.conf file, add the following

#Php模块加载
LoadModule php5_module "D:/software/greensoft/php/php5.4.6/php5apache2_2.dll"

#php. ini path settings
Phpinidir "d:/software/greensoft/php/php5.4.6/"

AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps

#加入后缀名过滤
AddHandler application/x-httpd-php. php

#或者以下配置应用过滤
<filesmatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>


Second, configure MySQL
In php.ini, modify the following configuration:

#修改php的扩展库目录为你的实际路径
Extension_dir = "D:/software/greensoft/php/php5.4.6/ext"

#去掉 #extension =php_mysql.dll in front of the #
Extension=php_mysql.dll

Third, install MySQL

MySQL: http://www.mysql.com/downloads/

After the download is made into the appropriate version of the compression pack. Unzip to the appropriate directory D:\Software\GreenSoft\MySql\MySql56.

1. Install MySQL as a service

Append D:\Software\GreenSoft\MySql\MySql56\bin to the system variable path of the Windows environment variable; , and enter the following command in the DOS window:

#进入mysql的bin目录cd d:\software\greensoft\mysql\mysql56\bin# Stop the MYSQL process that was opened before Mysqladmin-u root-p debug shutdown# Install the MySQL service. Specify the service name MySql56, configure the file name path mysqld--install MySql56--defaults-file=d:\software\greensoft\mysql\mysql56\my.cnf# start the service program net Start mysql56# Stop service program net stop mysql56/mysqladmin-u root shutdown# remove service mysqld--remove mysql56/sc Delete MySql56

#测试MySql
Mysqlshow
Mysqlshow-u Root MySql56
Mysqladmin Version Status proc
MySQL Test

2. Configure the MySQL configuration file

[mysqld]port=3306 # MySQL server default listener (listen on) TCP/IP Port ServerID = 1 socket =/tmp/mysql.sock basedir= "d:/software/ greensoft/mysql/mysql56/"# Datum root path datadir=" e:/dataroot/mysqldata/"# MYSQL Database file directory log-error=" D:/software/greensoft /mysql/mysql56/log/error.log "#错误日志文件log-slow-queries=" D:/software/greensoft/mysql/mysql56/log/slow-query.log " Character-set-server=latin1 # The character set used by the service side defaults to a 8-bit encoded latin1 character Set Default-storage-engine=innodb # The default storage engine that will be used when creating a new table Wait_ Timeout = #指定一个请求的最大连接时间, the server can be set to 5-10sql_mode=strict_trans_tables,no_auto_create_user,no_engine_ for about 4GB memory SUBSTITUTION # SQL Mode is strict mode max_connect_errors = 10000000 max_connections=100 # The maximum number of concurrent connections supported by the MySQL server Back_log = 384 #back_ The value of the log parameter indicates how many requests can be present in the stack for a short period of time before MySQL temporarily stops responding to a new request. If the system has many connections in a short period of time, you need to increase the value of this parameter, which specifies the size of the listening queue for incoming TCP/IP connections. Different operating systems have its own limitations on this queue size. Attempting to set a limit of back_log above your operating system will be invalid. The default value is 50. For Linux systems, the recommended setting is an integer less than 512. QUERY_CACHE_SIZE=32 # Query cache size, used to cache select query Results read_buffer_size=4m #默认为64K, # used for the buffer size used for full table scan of MyISAM table. Allocated for each thread (provided a full table scan is performed). When a sort query is made, MySQL will first scan through the slowTo avoid disk searches, improve query speed, and if you need to sort large amounts of data, you can adjust the value appropriately. However, MySQL will issue this buffer space for each client connection, so you should set this value as appropriately as possible to avoid excessive memory overhead. read_rnd_buffer_size=16m #默认为256K key_buffer_size=54m # key buffer size, which is used to cache the index block of the MyISAM table. Determines the speed of database index processing (especially index reads) sort_buffer_size=32m #默认为256K, connection-level parameters (configured for each thread), 500 threads consume 500*256k Sort_buffer_sizejoin _buffer_size = 8M #联合查询操作所能使用的缓冲区大小, as with Sort_buffer_size, the allocated memory for this parameter is also exclusive for each connection. Skip-locking #避免MySQL的外部锁定 to reduce the chance of error and increase stability. Skip-name-resolve #禁止MySQL对外部连接进行DNS解析, use this option to eliminate the time for DNS resolution for MySQL. However, it is important to note that if this option is turned on, all remote host connection authorizations will use IP address mode, otherwise MySQL will not be able to handle the connection request properly! skip-networking #开启该选项可以彻底关闭MySQL的TCP/IP connection, do not turn on this option if the Web server accesses the MySQL database server as a remote connection!  Otherwise it will not connect properly! table_cache=1024 #物理内存越大, the larger the setting. Default is 2402, 512-1024 best table_open_cache = 256 # Set the number of table caches tmp_table_size=34m # The maximum allowable size for each temporary table in memory, default is 16M, the maximum number of threads to 64-256 thread_cache_size=120 #默认为60 Cache thread_concurrency = 8 #该参数取值为服务器逻辑CPU数量 * 2, in this case, the server has 2 physical CPUs, and each physical CPU supports H.T Hyper-threading, so the actual value is 4*2=8 # InnoDB related Parameters innodb_additional_mem_pool_size=3m # InnoDB memory pool size used to store metadata information, generally without modification innodb_buffer_pool_size=105m # InnoDB use slowFlush the pool to cache the index and row data. The larger the value is set, the less disk IO. This value is typically set to 80% of physical memory. Innodb_flush_log_at_trx_commit = 1 # Transaction-related parameters, if the value is 1, InnoDB writes the transaction log to disk at each commit (disk IO consumption is large), which guarantees full acid performance. If set to 0, the transaction log writes to the memory log and the memory log writes to the disk at a frequency of 1 times per second. If set to 2, the transaction log is written to memory log at each commit, but the memory log is written to disk 1 times per second. INNODB_LOG_BUFFER_SIZE=2M # InnoDB The log data buffer size, and if the buffer is full, the log data in the buffer is written to disk (flush). Since the disk is usually written at least 1 seconds, there is no need to set it too large, even for a long transaction. innodb_log_file_size=53m # The size of each INNODB transaction log. 25% to 100%innodb_thread_concurrency=9 # InnoDB core Maximum number of concurrent threads for Innodb_buffer_pool_size # MyISAM related parameters Myisam_max_sort_file _size=100g # MySQL allows the maximum size of temporary files to be used when rebuilding indexes myisam_sort_buffer_size=68m

Configuration Description:

Basedir = Path Use the given directory as the root directory (the installation directory).
Character-sets-dir = Path Gives the directory where the character set is stored.
DataDir = Path Reads the database file from the given directory.
Pid-file = filename Specify a file that holds the process ID for the MYSQLD program (only for Unix/linux systems); The init-v script needs to use the process ID in this file to end the mysqld process.
socket = filename Specify a socket file for local communication between the MySQL client and the server (only for unix/linux systems; The default setting is typically/var/lib/mysql/mysql.sock files). In a Windows environment, if the MySQL client communicates with the server through a named pipe, the –sock option gives the name of the named pipe (the default setting is MySQL).
Lower_case_table_name = 1/0 Does the name of the new directory and data table only allow lowercase letters; The default setting for this option in the Windows environment is 1 (lowercase letters only allowed).

MYSQLD Program: Language Settings

Character-sets-server = Name The default character set for the new database or data table. To maintain compatibility with earlier versions of MySQL, this character set can also be given with the –default-character-set option; But this option has become a bit outdated.
Collation-server = Name The default sort method for a new database or datasheet.
Lanuage = Name Displays an error message in the specified language.

MYSQLD Program: Communication, network, information security

Enable-named-pipes Allows customers and servers in a Windows 2000/XP environment to communicate using named pipes (named pipe). The default name for this named pipe is MySQL, but it can be changed with the –socket option.
Local-infile [= 0] Allow/disallow the use of the load DATA Local statement to process local files.
Myisam-recover [=opt1, Opt2, ...] Automatically repairs all damaged MyISAM data tables at startup. There are 4 acceptable values for this option: default, BACKUP, quick, and force; They function identically to the same name as the MYISAMCHK program.
Old-passwords Use the old algorithms in MySQL versions 3.23 and 4.0 to encrypt passwords in the MySQL database (the new encryption algorithm introduced by default with MySQL version 4.1).
Port = N Specify a TCP/IP communication port (typically 3306 port) for the MySQL program.
Safe-user-create Only a user with insert permission on a Mysql.user database table can use the grant command; This is a double-insurance mechanism (this user must also have grant permission to execute the grant command).
Shared-memory Allows communication using memory (for Windows only).
Shared-memory-base-name = Name Give a name to the shared memory block (the default name is MySQL).
Skip-grant-tables Do not use the information in the MySQL database for access control (warning: This will allow any user to modify any database).
Skip-host-cache Do not use the cache area to store the host name and IP address correspondence.
Skip-name-resovle The IP address is not resolved to the host name; The checks related to access control (mysql.user data table) are all traveling through an IP address.
Skip-networking Local connections are allowed only through a socket file (Unix/linux system) or through Named pipes (Windows systems), and ICP/IP connections are not allowed; This improves security, but it blocks external connections from the network and all Java client programs (Java customers use TCP/IP even in local connections).
user = Name MYSQLD program will be executed under a given Unix/linux account after launch; Mysqld must be started from the root account in order to switch to another account after booting; The Mysqld_safe script will use the –USER=MYSQL option by default to start the MYSQLD program.

MYSQLD Program: Memory management, optimization, query buffer

Bulk_insert_buffer_size = n The buffer length assigned to the INSERT command that inserts multiple new records at one time (the default setting is 8M).
Key_buffer_size = n The RMA value used to hold the index chunk (the default setting is 8M).
Join_buffer_size = n The buffer length allocated for the join operation when the data column participating in the JOIN operation is not indexed (the default setting is 128K).
Max_heap_table_size = n Maximum length of the heap data table (default setting is 16M); More than this length of the heap data table will be stored in a temporary file instead of residing in memory.
Max_connections = n The maximum number of database connections that the MySQL server processes concurrently (the default setting is 100).
Query_cache_limit = n The maximum length of the query result that is allowed to be temporarily stored in the query buffer (the default setting is 1M).
Query_cache_size = n The maximum length of the query buffer (default setting is 0, does not open the query buffer).
Query_cache_type = 0/1/2 Query the operating mode of the buffer: 0, disable the query buffer; 1. Enable query buffers (default setting); 2, "On demand" mode, only responds to the Select Sql_cache command.
Read_buffer_size = n The length of the buffer reserved for read operations that read data from the data table order (the default setting is 128KB); The setting value of this option can be changed with the SQL command set SESSION read_buffer_size = n command when necessary.
Read_rnd_buffer_size = n Similar to the Read_buffer_size option, but for query results that are output in a particular order (for example, a query that uses an ORDER BY clause) (the default setting is 256K).
Sore_buffer = n The length of the buffer allocated for the sort operation (the default setting is 2M); If the buffer is too small, you must create a temporary file to sort it.
Table_cache = n The number of data tables that are open at the same time (the default setting is 64).
Tmp_table_size = n The maximum length of the temporary heap data table (the default setting is 32M); A temporary data table over this length will be converted to a MYISAM data table and stored in a temporary file.

MYSQLD Program: Log

Log [= file] Log all connections and all SQL commands (common query log); If the file parameter is not given, MySQL will create a hostname.log file in the database directory as the log file (hostname is the hostname of the server).
log-slow-queries [= file] Log query commands that exceed the value of the Long_query_time variable when executing (slow query log); If the file parameter is not given, MySQL will create a hostname-slow.log file in the database directory as the log file (hostname is the server hostname).
Long_query_time = n Maximum execution time for slow queries (the default setting is 10s).
Long_queries_not_using_indexs Log the slow query and query commands that do not use indexes at execution time (the rest of the same –log-slow-queries option).
Log-bin [= filename] All SQL commands that modify the data (that is, the INSERT, update, and delete commands) are logged in binary format (binary change log, binary update logs). The file name for this log is FILENAME.N or the default HOSTNAME.N, where N is a 6-digit integer (the log file is sequentially numbered).
Log-bin-index = filename The index file name of the binary logging feature. By default, this index file is the same name as the binary log file, but the suffix name is. index instead of. nnnnnn.
Max_binlog_size = n The maximum length of the binary log file (the default setting is 1GB). Before the amount of information in the previous binary log file exceeds this maximum length, the MySQL server automatically provides a new binary log file on the continuation.
Binlog-do-db = dbname Only the changes in the given database are recorded in the binary log file, the changes in other databases are not recorded. If you need to record changes in multiple databases, you must use multiple this option in the configuration file to set one row per database.
Binlog-ignore-db = dbname Do not log changes in a given database into a binary logfile.
Sync_binlog = n Log files are written to the hard disk once per n logs (log information is synchronized once). N=1 is the safest approach, but the least efficient. The default setting is N=0, which means that the operating system is responsible for synchronizing the binary log files.
log-update [= file] Log file name (error log) that describes the error condition. This logging feature cannot be disabled. If the file parameter is not given, MySQL uses Hostname.err as the name of the log file.

MYSQLD Program: Mirroring (Master mirror server)

Server-id = n Assign a unique ID number to the server; The value range of n is 32 times the binary log enabled function.
Log-bin = Name Enables the binary logging feature. The file name for this log is FILENAME.N or the default HOSTNAME.N, where N is a 6-digit integer (the log file sequence number).
Binlog-do/ignore-db = dbname Only the changes in the given database are recorded in the binary log file/the changes in the given database are not logged into the binary log file.

MYSQLD Program: Mirroring (secondary mirror server)

Server-id = n Assign a unique ID number to the server
Log-slave-updates Enable the logging feature on the subordinate server so that this computer can be used to form a mirror chain (a->b->c).
Master-host = hostname Host name or IP address of the master server. If a mater.info file exists on the secondary server (the mirror relationship definition file), it ignores this option.
Master-user = Replicusername The user name that the secondary server uses to connect to the master server. If a mater.info file exists on the subordinate server, it ignores this option.
Master-password = passwd The password that the secondary server uses to connect to the master server. If a mater.info file exists on the subordinate server, it ignores this option.
Master-port = n The TCP/IP port that the secondary server uses to connect to the master server (the default setting is 3306 ports).
Master-connect-retry = n If the connection to the master server is unsuccessful, wait for n seconds (s) before managing it (the default setting is 60s). If a subordinate server exists with a mater.info file, it ignores this option.
master-ssl-xxx = xxx Configure the SSL communication between the master and slave servers.
Read-only = 0/1 0: Allow slave server to execute SQL command independently (default setting); 1: The secondary server can only execute SQL commands from the master server.
Read-log-purge = 0/1 1: Delete the processed SQL command immediately from the log file (default setting); 0: Do not remove the processed SQL commands from the log file immediately.
Replicate-do-table = Dbname.tablename The meaning and usage of the –replicate-do-table option is the same, but the wildcard "%" is allowed in the database and database table names (for example: test%.%– mirrors the database tables in all databases whose names begin with "test").

REPLICATE-DO-DB = Name This database is only mirrored.
Replicate-ignore-table = Dbname.tablename Do not mirror this data table.
Replicate-wild-ignore-table = Dbn.tablen These data tables are not mirrored.
Replicate-ignore-db = dbname Do not mirror this database.
Replicate-rewrite-db = db1name > Db2name Db1name database mirroring on the master database is processed as a db2name database on the subordinate server.
Report-host = hostname The host name of the subordinate server; This information is only relevant to the show SLAVE hosts command – The master server can use this command to generate a list of subordinate servers.
Slave-compressed-protocol = 1 The master and slave servers use a compressed format for communication-if they all support this.
Slave-skip-errors = n1, N2, ... or all Even if the error code is N1, N2, and so on, the mirroring process continues (that is, the mirroring process continues regardless of any errors). If configured properly, the subordinate server should not have an error executing the SQL command (the SQL command executing the error on the master server will not be sent to the secondary server for mirroring); If you do not use the slave-skip-errors option, the mirror work on the subordinate server may be interrupted due to an error, and manual intervention is required to continue.

Mysqld–innodb: Basic settings, tablespace files

Skip-innodb Do not load InnoDB datasheet driver – You can save some memory with this option if you do not need to innodb the datasheet.
Innodb-file-per-table Create a tablespace file for each new data table instead of storing the data tables centrally in the central table space (the latter is the default setting). This option is seen in MySQL 4.1.
Innodb-open-file = n InnoDB the number of files that the data table driver can open at the same time (the default setting is 300). If you use the innodb-file-per-table option and you need to open many data tables at the same time, this number is likely to need to be increased.
Innodb_data_home_dir = P InnoDB The home directory, all directories or file paths related to the INNODB data table are relative to this path. By default, this home directory is the MySQL data directory.
Innodb_data_file_path = ts Table space used to hold innodb as a data table: More than one file may be involved; The maximum length of each tablespace file must be given in bytes (B), megabytes (MB), or gigabytes (GB); The name of the tablespace file must be separated by semicolons; The last Tablespace file can also take a Autoextend property and a maximum length (max:n). For example, ibdata1:1g; IBDATA2:1G:AUTOEXTEND:MAX:2G means: The maximum length of the tablespace file ibdata1 is 1gb,ibdata2 maximum length is 1G, but it is allowed to expand to 2GB. In addition to the file name, you can also use the hard disk partition's setting name to define the table space, you must give the maximum initial length value of the tablespace plus the Newraw keyword suffix, the maximum extended length value of the table space plus the raw keyword suffix (such as/dev/hdb1:20gnewraw or/dev/ Hdb1:20graw); The default setting for MySQL version 4.0 and later is ibdata1:10m:autoextend.
Innodb_autoextend_increment = n The tablespace file with the Autoextend property increases the number of megabytes per time (the default setting is 8MB). This property does not involve specific data table files, and those files are relatively small in speed.
Innodb_lock_wait_timeout = n If a transaction has not obtained the required resources after waiting for n seconds (s), use the rollback command to discard the transaction. This setting is important for discovering and handling deadlock conditions that are not recognized by the INNODB data table driver. The default setting for this option is 50s.
Innodb_fast_shutdown 0/1 Whether the InnoDB is turned off at the fastest speed, the default setting is 1, which means that the data cached in the insert buffer is not written to the data table, and those data will be written again at the next startup of the MySQL server (there is no risk because the insert buffer is an integral part of the tablespace, Data is not lost). Set this option to 0 negative because the InnoDB driver is likely not to have enough time to complete its data synchronization when the computer shuts down, and the operating system may forcibly end InnoDB before it completes the data synchronization, which results in incomplete data.

MYSQLD Program: innodb– Log

innodb_log_group_home_dir = P The directory path used to hold the InnoDB log file (such as IB_LOGFILE0, Ib_logfile1, and so on). By default, the InnoDB driver uses the MySQL data directory as the location where you save the log files.
innodb_log_files_in_group = n How many log files are used (the default setting is 2). The InnoDB data table driver will fill in these files in turn; When all log files are full, the log information that follows is written to the maximum length of the first log file (the default setting is 5MB). This length must be set in megabytes (megabytes) or GB (gigabytes).
innodb_flush_log_at_trx_commit = 0/1/2 This option determines when log information is written to the log file and when the files are physically written (the term "synchronization") To the hard disk. Setting the value 0 means that the log is written and synchronized every second, which can reduce the number of hard disk writes, but may result in data loss; Setting the value 1 (setting) means that the log is written and synchronized each time a commit is executed, which prevents data loss, but the hard disk write operation can be very frequent; Setting a value of 2 is a general tradeoff, that is, each execution of a commit command writes a log of the next day, synchronizing every second.
innodb_flush_method = x InnoDB Log file synchronization method (only applicable to Unix/linux systems). There are two desirable values for this option: Fdatasync, which is synchronized with the Fsync () function; O_dsync, use the O_sync () function to synchronize.
innodb_log_archive = 1 enables the archive (archive) log feature of the InnoDB driver to write log information to the Ib_arch_log_n file. Enabling this logging feature does not make much sense when InnoDB is used with MySQL (it is sufficient to enable the binary logging feature of the MySQL server).

MYSQLD program –innodb: Setting and optimization of buffers

Innodb_log_buffer_pool_size = n The amount of RAM memory that is reserved for INNODB data tables and their indexes (the default setting is 8MB). This parameter has a considerable effect on speed, and if only the MYSQL/INNODB database server is running on the computer, 80% of all memory should be used for this purpose.

Innodb_log_buffer_size = n Maximum length of the transaction log file write buffer (default setting is 1MB).
Innodb_additional_men_pool_size = n The maximum length of the buffer allocated for the various data structures used for internal administration (the default setting is 1MB).
Innodb_file_io_threads = n The maximum number of threads for I/O operations (hard disk write) (default setting is 4).
Innodb_thread_concurrency = n The maximum number of threads that the InnoDB driver can use at the same time (the default setting is 8).

MYSQLD Program: Other options

Bind-address = ipaddr The IP address of the MySQL server. This option is important if the computer on which the MySQL server resides has multiple IP addresses.
Default-storage-engine = Type The default data table type for the new data table (the default setting is MyISAM). This setting can also be set by the –default-table-type option.
Default-timezone = Name Set a geographic time zone for the MySQL server (if it is not the same as the local computer's geographic time zone).
Ft_min_word_len = n Minimum word length work for full-text indexing. The default setting for this option is 4, meaning that when you create a full-text index, you do not consider those words that are constructed from 3 or fewer characters.
Max-allowed-packet = n The maximum length of packets exchanged between the customer and the server, which should be at least greater than the length of the maximum blob block that the client program will process. The default setting for this option is 1MB.
Sql-mode = Model1, Mode2, ... The SQL mode in which MySQL will run. The purpose of this option is to allow MySQL to maintain maximum compatibility with other database systems. The desirable values for this option include ANSI, DB2, Oracle, No_zero_date, Pipes_as_concat.

Reprint: Installation and configuration of Php,mysql

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.