PHP 7.0 Compile and install MySQL
MySQL is a widely used relational database management system. Its efficiency and reliability make it one of the most popular databases in web development. At the same time, PHP, as a popular server-side scripting language, is also loved by many developers. In this article, we will discuss how to compile and install MySQL in PHP 7.0.
Step 1: Install related dependencies
The compilation and installation of MySQL requires some related software packages and libraries. In Debian-based operating systems such as Ubuntu or Debian, you can install these dependencies using the following command:
sudo apt-get update
sudo apt-get install build-essential
sudo apt- get install libmysqlclient-dev
sudo apt-get install libxml2-dev
Step 2: Download and decompress MySQL
Download the latest version of the MySQL source code package from the MySQL official website. Download link: https://dev.mysql.com/downloads/mysql/.
Unzip the source code package:
tar -zxvf mysql-5.XX.XX.tar.gz
Step 3: Configure and compile MySQL
The MySQL source code obtained after decompression directory, perform the following configuration and compilation:
./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets =all \
--with-pthread \
--enable-thread-safe-client \
--with-ssl \
--with-mysqli=mysqlnd \
-- with-pdo-mysql=mysqlnd \
--enable-shared \
--enable-static \
--with-libdir=lib64 \
--with-openssl
Parameter options here include:
--prefix: Specify the installation directory as /usr/local/mysql.
--with-charset: Set the default character set to utf8.
--with-extra-charsets: Set the character sets supported by MySQL.
--with-pthread: Enable threads.
--enable-thread-safe-client: Enable thread-safe client.
--with-ssl: Enable SSL.
--with-mysqli: Enable the MySQLi extension (skip this option if you don't need this extension).
--with-pdo-mysql: Enable the PDO MySQL extension (skip this option if you don't need this extension).
--enable-shared: Use shared libraries during installation.
--enable-static: Use static libraries during installation.
--with-libdir: Set the library directory.
--with-openssl: Enable OpenSSL.
After successful configuration, use the make command to compile:
make
Step 4: Install MySQL
After completing the compilation, use the following command to install MySQL to the specified directory :
sudo make install
Step 5: Set up MySQL
After the installation is complete, use the following command to set the MySQL environment variable:
export PATH=$PATH:/ usr/local/mysql/bin
Then, use the following command to start the MySQL server:
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
Then, use the following command to log in to MySQL:
mysql -u root -p
If you have set a MySQL password, enter the password to log in. If you haven't set a password yet, set it using the following command:
mysqladmin -u root password "newpassword"
Here, "newpassword" should be replaced with the actual password.
At this point, you have successfully compiled and installed MySQL in PHP 7.0 and can start using it to process your web application data.
The above is the detailed content of How to compile and install mysql in php 7.0. For more information, please follow other related articles on the PHP Chinese website!