Build a php environment with the source code in linux mysql (1)

Source: Internet
Author: User
Tags mysql command line
It's already midnight, and May Day is boring. You can't sleep. Therefore, install a virtual machine on the computer, and then build a p

It's already midnight, and May Day is boring.

You can't sleep. You can install a virtual machine on your computer. then, you can build a php environment on the virtual machine.

First, install MYSQL. I found many problems .. I will try again later.

The installation steps on a website are as follows:

This section mainly introducesMysqlThe source code is manually installed. if you are interested in the actual manual installation process of the MySQL source code in the linux operating system, you may wish to browse the following articles.

Bytes

2. decompress tar -xvfMySQL-5.0.87.tar.gz

3. enter MySQL-5.0.87

4. check the Environment and specify the installation directory:./configure -- prefix =/usr/local/MySQL

5. Compile: make

6. install: sudo make install

7. configuration is required during installation of MySQL source code in linux. First, you can see the following directory after installation:

Run the following command in share/MySQL: ls-l | grepmy-

All MySQL configuration files are displayed. select one of them as needed and copy them to/etc and name them my. cnf.

/Etc/my. cnf is the path of the configuration file read by MySQL by default.

8. modify the write permission of var. This is the location where MySQL database data files are stored, because the background program running MySQL by the current user may not have the write permission for this directory.

Chmod 777./var-r

9. configure system environment variables so that MySQL programs can be directly executed.

The system environment variables are stored in/etc/profile, and the user's environment variables are stored in. bashrc under the user's root directory.

/Etc/profile configuration:

PATH =/usr/local/MySQL/bin: $ PATH =/usr/local/MySQL/libexec: $ PATH

10. initialize MySQLd and execute MySQL_install_db.

11. directly call mysqld_safe & start mysql because environment variables have been configured before.

12. directly access MySQL command line control. The default logon mode is the current user name. The default root mode has no password.

13. set the root password: MySQLadmin-u rootpassword '123'

14. log on as root: MySQL-uroot-p

15. set remote database logon. After a user is created, the user can only log on locally by default.

Update user set Host = '%' where user = 'guoyu ';

Change the permitted logon address of guoyu to any address, but not local. That is to say, the user guoyu cannot log on locally, but can only log on remotely.

Only the root user can execute this statement. Therefore, you must first log on to the local database as the root user.

Flush privileges;

16. stop mysql: mysqladminshutdown

This refresh cache statement takes effect. The above content is an introduction to the installation of manual MySQL source code in linux. I hope you will have some gains.

Problem 1:

No targets specified and no makefile found. Stop.
Solution:
Yum install gcc-c ++ autoconf automake

Problem 2: Permission denied
Permission denied in linux

Permission denied occurs when you install something on linux:
Solution:
Edit/etc/selinux/config and find the following link:
# This file controls the state of SELinux on the system.
# SELINUX = can take one of these three values:
# Enforcing-SELinux security policy is enforced.
# Permissive-SELinux prints warnings instead of enforcing.
# Disabled-SELinux is fully disabled.
SELINUX = enforcing


Comment out SELINUX = enforcing: # SELINUX = enforcing, and add a new line:
SELINUX = disabled
Save and close.
......

Edit/etc/sysconfig/selinux and find:
# This file controls the state of SELinux on the system.
# SELINUX = can take one of these three values:
# Enforcing-SELinux security policy is enforced.
# Permissive-SELinux prints warnings instead of enforcing.
# Disabled-SELinux is fully disabled.
SELINUX = enforcing

If SELINUX is already set to SELINUX = disabled, you do not need to change it. otherwise

SELINUX = enforcing: comment out and add a new line:
SELINUX = disabled
Save and exit.

If you encounter other similar prompts:
Cannot restore segment prot after reloc: Permission denied
Which of the following is SELinux? you can disable SELinux.
----------------------------------------------------------------
---------------------
Sadly, I disabled SELinux but it still didn't work. so I went to google to search and found this

Very useful.
After you ensure that SElinux is disable, execute
Chcon-t texrel_shlib_t
For example, chcon-t texrel_shlib_t/path/name. so (this file depends on the specific execution file .)
The above two steps have solved many server problems. Problem 3: no ROOT permission

Solution:

Open the terminal and enter [root @ localhost ~] in the terminal # Su

Problem 4: in the tar,./configure, make, and make install Classic 4 steps, I never thought about the process. I just thought it was just like a routine task.
Unfortunately, the following error occurs in make after./configure:
Make: *** No targets specified and no makefile found. stop.

Solution:
Find the relevant information on the Internet and check whether a./configure error occurs. then, you can check it and find the problem: the last few lines have an error. The complete error message is as follows:
Checking for tgetent in-lncurses... no
Checking for tgetent in-lcurses... no
Checking for tgetent in-ltermcap... no
Checking for tgetent in-ltinfo... no
Checking for termcap functions library... configure: error: No
Curses/termcap library found

Cause:
The ncurses installation package is missing

Solution:
Download and install the software package
1. if your system is a RedHat series:
Yum list | grep ncurses
Yum-y install ncurses-devel
Yum install ncurses-devel

2. if your system is Ubuntu or Debian:
Apt-cache search ncurses
Apt-get install libncurses5-dev

Completed to be installed! And then./configure, and then make & make
Install, install successfully, everything is OK !~~ Problem 5: bash: mysql: command not found
Solution:
The first problem is that the path of your mysql command is under/usr/local/mysql/bin, so when you directly use the mysql command, the system cannot find this command under/usr/bin. the solution is to link ln-s/usr/local/mysql/bin/mysql/usr/bin,
The second problem is that you did not specify the password parameter, so mysql-uroot-p
Or directly use the relative path./mysql-uroot-p123456

The installation of a MYSQL database encountered so many problems. Fortunately, the installation was successful.

The installation process is summarized as follows:

Bytes

2. decompress tar-xvf MySQL-5.0.87.tar.gz

3. enter MySQL-5.0.87

4. check the Environment and specify the installation directory:./configure -- prefix =/usr/local/MySQL. install whatever is detected. If no gcc or g ++ exists, you must download the rpm Package (compiled binary file) and install it on the system without a compiler. The following is the command to install gcc (to download this package first, this address has a lot of rpm Package download http://mirror.oa.com/SLES10-SP1-RPMS-32 ):

Sudo rpm-ivh gcc-4.1.2_20070115-0.11.i586.rpm

Some of these rpm packages are installed, or they cannot be installed because they are dependent on themselves. if they cannot be installed, use the command to force installation and ignore dependencies.

Sudo rpm-ivh gcc-4.1.2_20070115-0.11.i586.rpm -- force-nodeps

After installing a series of rmp packages, the environment detection is completed ......

5. Compile: make

6. install: sudo make install

7. configuration is required during installation of MySQL source code in linux. First, you can see that the installed directory is as follows:

Ls-l | grep my-

All MySQL configuration files are displayed. select one of them as needed and copy them to/etc and name it my. cnf/etc/my. cnf, which is the path of the configuration file read by MySQL by default.

8. modify the write permission of var. This is the location where MySQL database data files are stored, because the background program running MySQL by the current user may not have the write permission for this directory.

Chmod 777./var-r

9. configure the system environment variables so that the environment variables of the MySQL program system can be directly executed are placed under/etc/profile, and the user's environment variables are placed under the user's root directory. configuration of (1)/etc/profile in bashrc: PATH export PATH where/usr/local/mydql/bin is the directory of MySQL main executable programs, while libexec stores MySQL's main background program MySQLd.

(2). bashrc configuration:

Set PATH =/usr/local/MySQL/bin: $ PATH

Set PATH =/usr/local/MySQL/libexec: $ PATH

Export PATH. Note that a set must be added to bashrc. After the configuration is complete, re-login will take effect.

10. initialize MySQLd and execute MySQL_install_db.

11. start MySQLd and press MySQLd directly, because the system environment variables have been configured before.

12. directly access MySQL command line control. The default logon mode is the current user name. The default root mode has no password.

13. set the root password: MySQLadmin-u root password '123'

14. log on as root: MySQL-uroot-p

15. set remote database logon. After a user is created, the user can only log on locally by default. Update user set Host = '%' where user = 'guoyu'; change the permitted logon address of guoyu to any one, but not local. That is to say, the user guoyu cannot log on locally, but can only log on remotely. Only the root user can execute this statement. Therefore, you must first log on to the local database as the root user. Flush privileges; refresh the cache to take effect. The above content is an introduction to the installation of manual MySQL source code in linux. I hope you will have some gains.

Finally, find the MYSQL configuration information on the Internet:

1. configure the startup service
/Sbin/chkconfig httpd on [set the startup of the httpd service on the apache server]
/Sbin/chkconfig-add mysqld [add mysql service to service list]
/Sbin/chkconfig mysqld on [set mysql service startup]
/Sbin/service httpd start [start the httpd service, which has nothing to do with startup]
/Sbin/service mysqld start [start mysql service, irrelevant to startup]

2. set the password of the root account of the mysql database. The default initialization password is null ~~~
Mysqladmin-u root password 'new-password' [enter the password in quotation marks]

3. make mysql database more secure
Mysql-u root-p
Mysql> drop database test; [delete the test DATABASE]
Mysql> delete from mysql. user WHERE user = "; [deleting anonymous accounts]
Mysql> flush privileges; [reload permissions]
4. install mysql extension
Yum-y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
5. set the default encoding and other initial parameters (my. cnf)
Vi/etc/my. cnf
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
User = mysql
Default-character-set = utf8 [add]
Default-storage-engine = INNODB [add]
Old_passwords = 1
[Client]
Default-character-set = utf8 [add]
[Mysqld_safe]
Log-error =/var/log/mysqld. log
Pid-file =/var/run/mysqld. pid
 

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.