PHP pdo_mysql Extension Installation steps

Source: Internet
Author: User
Tags zts zend

Reprint Address: http://www.cnblogs.com/qq78292959/p/4084868.html

Seeing the cakephp documentation requires you to install the pdo_mysql extension, you try to install it.

My system here is CentOS 6.0. If your system is a different version of Linux/unix, you can refer to it. If your system is windows, sorry, the following is not suitable for you, please go.

The first is to download the pdo_mysql extension of the source package. The download page is here: Http://pecl.php.net/package/PDO_MYSQL. You can download it first and then upload it to the server using FTP.

I was copying it later using wget to download directly to the server side.
# wget Http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

Then the decompression.
# TAR-ZXVF Pdo_mysql-1.0.2.tgz

Enter the extracted directory and execute the phpize.
#/usr/local/php/bin/phpize
Configuring for:
PHP Api version:20100412
Zend Module Api no:20100525
Zend Extension Api no:220100525

The following generates makefile. The following two parameters must be added, I did not add at the beginning, the results are not found in the Php-config and MySQL header files.
#./configure–with-php-config=/usr/local/php/bin/php-config–with-pdo-mysql=/usr/local/mysql

Make a soft connection to the header file of MySQL before making it. Because MySQL installs the time to specify the directory, does not make the soft connection, still cannot find the header file.
# ln-s/usr/local/mysql/include/*/usr/local/include/

Then make and make install.
# make
# make Install

You will then be prompted as follows, meaning that the extension is installed in the following directory.
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20100525/

For convenience, I moved the pdo_mysql.so file to the extensions directory.
# mv/usr/local/php/lib/php/extensions/no-debug-zts-20100525/pdo_mysql.so/usr/local/php/lib/php/extensions/

You can then modify the php.ini file.

Find Extension_dir = "./" This line, remove the comment, and modify the path.
Extension_dir = "/usr/local/php/lib/php/extensions/"
I tested this and found that PHP only looked for extensions from that directory, not subdirectories in that directory. So I moved the so file to this directory for unified management.

Find Extension=php_pdo_mysql.dll this line, remove the comment, and modify the file name later.
Extension=pdo_mysql.so
File name is not the same, the PHP_ prefix is removed, otherwise the file cannot be found. Behind the DLL is the name of the file under Windows, we changed to so.

The final restart of Apache is possible. Use Phpinfo () to see that the discovery has taken effect.

There is a problem connecting to MySQL database today: Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)

Refer to the relevant methods on the Internet, including: (Http://blog.csdn.net/lmss82/archive/2009/08/05/4414178.aspx)

Scenario 1.
 1. #ps-a|grep MySQL
   show similar:
  1829?        00:00:00 mysqld_safe
   1876?        00:00:31 mysqld
  2.# Kill-9 1829
  3. #kill-9 1876
  4.#/etc/init.d/mysql restart
  5. #mysql-u root-p
 
   His trouble solved, I have not solved!
 
Continue looking for
Scenario 2
to see/ETC/RC.D/INIT.D/MYSQLD status first to see if M y S Q l have been started.
Also see if it is a permission issue.
------------------------------------------------------------------------------------
[[email  Protected] Beinan] #chown-R mysql:mysql/var/lib/mysql
[[email protected] beinan]#/etc/init.d/mysqld start
Start MySQL: [OK]
[[email protected] lib]# mysqladmin-uroot password ' 123456 '
[[email protected] Lib ]# mysql-uroot-p
Enter Password:
Welcome to the MySQL monitor. Commands End With; or/g.
Your MySQL Connection ID is 3 to server version:4.1.11

Type ' help; ' or '/h ' for help. Type '/C ' to clear the Buffe

His also solved, my trouble continues, still continue to look for

Scenario 3
Problem solved, unexpectedly is max_connections=1000 he said too much, and then changed to 500 also said more, but delete the problem solved.

Or not?
Scenario 4

/var/lib/mysql all file permissions to Mysql.mysql

No, No.

Scenario 5
Summary: Troubleshooting cannot be done via MySQL. Sock connection MySQL problem The main hint is that you cannot connect to the server through '/tmp/mysql. Sock ', while the PHP standard configuration uses '/tmp/mysql. Sock ', but some MySQL installation methods will MySQL. Sock placed in/var/lib/mysql sock or somewhere else, you can modify the/etc/my.cnf file to fix it, open the file, you can see the following:
[MySQL d]
Socket=/var/lib/mysql. Sock
Change it, but it will also cause other problems, such as the MySQL program is not connected, add a bit:
[MySQL]
Socket=/tmp/mysql. Sock
Or you can modify the configuration in the php.ini to make PHP use the other MySQL. Sock, this is for everyone to find.
  
Or in such a way:
Ln-s/var/lib/mysql/mysql. Sock/tmp/mysql. Sock

That's it, Ln-s/var/lib/mysql/mysql. Sock/tmp/mysql. Sock

Ok!

PHP pdo_mysql Extension installation steps

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.