Liunx installing MySQL

Source: Internet
Author: User
Tags zts zend

1. Download
Download mysql-5.1.65.tar.gz on official website (note that the source package)

You can also directly copy the 64-bit, download by command: wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2. Decompression
TAR-ZXVF mysql-5.1.65.tar.gz
3. Set up the target folder
Mkdir/usr/local/mysql
In other words, wait for the installation of MySQL to install into this folder
4. Configuration
./configure--prefix=/usr/local/mysql/

in./configure error occurred: Error:no Curses/termcap Library found

Download and install the appropriate package

Yum List|grep ncurses

Yum-y Install Ncurses-devel

Yum Install Ncurses-devel

5. Compiling
Make
6. Installation
Make install

7. Start
The MySQL service does not start automatically, and the MySQL database needs to be initialized first, as follows:
Cd/usr/local/mysql/bin
sudo./mysql_install_db--user=root
Note that the last root in this case refers to the user who can manipulate the database, either the current user or a new user, and the root user on Linux is different, so you can take a name for yourself.
./mysqld_safe--user=root & This command is responsible for starting the daemon of the MySQL service, in addition to the final & must, because you want the daemon to run in the background
The root here is the one that was just there.
8. Create a password for the root user
./mysqladmin-u root password ' 123456 '
If Root has already set a password, use the following method
./mysqladmin-u root Password oldpass ' 123456 '
9. Testing
Mysql-u root-p
You will be prompted to enter your password, just use the password you just set
123456
If Mysql> is present, the connection is successful, the following command creates a database, builds a table, adds a record, prepares for subsequent tests

mysql> CREATE DATABASE Gywtest;
mysql> use gywtest;

Mysql> CREATE TABLE student (ID int (4) NOT null primary key Auto_increment,stuname char (20));

mysql> INSERT into student (Stuname) VALUES (' Tom ');

Note that there is a semicolon behind each command, and if all of the above are successful, you can use this test later.

Iv. combining PHP with MySQL

1, reconfigure PHP, change the configuration options, simply repeat the PHP installation of the last three steps configure, make, and made install, and then need to restart Apache for the new module to take effect, Apache does not need to recompile.

2. Configuration

./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-mysqli=/usr/local/mysql/bin/ Mysql_config Note the path of Mysql_config
3. Compile make

4. Install Make Installe

5, test write a page test.php, placed in the Apache web directory, test the above with the command to create a database

<?php
$mysqli =new mysqli ();
$mysqli->connect (' localhost ', ' root ', ' 123456 ', ' gywtest ');
Create a query
$SQLSTR = ' SELECT * from student ';
Send a query to MySQL
$result = $mysqli->query ($SQLSTR);
while ($row = $result->fetch_object ())
{
$name = $row->stuname;
Echo $name;
}
?>

Fatal error:class ' mysqli ' not found in/home/lufangtao/project/db.php on line 3

Workaround:

/usr/local/php/bin/phpize here return to run

Error:

Cannot find CONFIG.M4.
Make sure this you run './phpize ' in the top level source directory of the module

Workaround:

PHP Source Package folder under the Ext folder is the current version of the available extensions, CD in to see what you need? You should see the Mysqli folder.

Executing phpize in the current directory

[Email protected] Mysqli]#/usr/local/php/bin/phpize

Configuring for:

PHP Api version:20090626

Zend Modeule Api no:20090626

Zend Extension Api no:220090626

Cannot find autoconf. Please check your autoconf installation and the
$PHP _autoconf environment variable. Then, rerun the this script.

Workaround:

Yum Install autoconf run the above command again.

[Email protected] mysqli]#./configure–prefix=/opt/mysqli–with-php-config=/opt/php/bin/php-config–with-mysqli=/ Opt/mysql/bin/mysql_config

[[email protected] mysqli] #make

[[email protected] mysqli] #make Install

After the installation is complete, you will be prompted to expand the directory path, such as:

/opt/php/lib/php/extensions/no-debug-zts-20090626php

The required mysqli.so will be in this directory, next modify the php.ini file under/opt/php/etc/, add the mysqli extension, that is, add the following line:

Extension=/opt/php/lib/php/extensions/no-debug-zts-20090626/mysqli.so

The solution in Linux is a little more complicated, because it's all command mode.

The code is as follows Copy Code


CD php-5.2.8//There's a mysqli in the Ext folder below.
CD Ext/mysqli

Linux will be the source file compiled should have configure it, but here is not, after we have installed PHP, php5 this folder in the command directory bin has a file called phpize, use it can generate configure file, continue

The code is as follows Copy Code

/usr/local/php5/bin/phpize//Here Enter run, after the execution of the Configure file,
./configure–prefix=/usr/local/mysqli–with-php-config=/usr/local/php5/bin/php-config–with-mysqli=/usr/local/ Mysql/bin/mysql_config

Direct return, no problem on the continue.

The code is as follows Copy Code

Make
Make Test
Make install//(will show installing shared extensions:/usr/local/php5/lib/php/extensions/no-debug-non-zts-20041030/) without error

Now the mysqli.so file is out.

It is OK to load this file directly in the php.ini.

The code is as follows Copy Code

Extension_dir= "/usr/local/php5/ext"
Extension=mysqli.so

Find the first line above and change it to this, then add the second line. Wq Save exit.

Put mysqli.so this file CP to/usr/local/php5/ext

Liunx installing MySQL

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.