Install mysql-5.0.45.tar.gz,mysql5.0.41.tar.gz

Source: Internet
Author: User

Install mysql-5.0.45.tar.gz,mysql5.0.41.tar.gz

Installation environment: VMware9 (Bridge Mode) + Linux bogon 2.6.32-642.3.1.el6.x86 _ 64 (view linux version: uname-)

MySQL For Linux source code, is xx.tar. zg format, as follows: http://www.filewatcher.com/m/mysql-5.0.45.tar.gz.24433261.0.0.html

 

1. Install mysql in the source code package.

------------- Preparations ----------

1: If the downloaded file name: mysql-5.0.45.tar.gz

2: copy to/usr/local/software. (The software packages are stored in this directory)

3: groupadd mysql # Add a mysql Group

4: useradd-g mysql-s/bin/false # create a user mysql and add it to the mysql group. mysql users are not allowed to log on to the system directly.

Mkdir-p/usr/local/mysql # create the MySQL installation directory

Mkdir-p/usr/local/mysql/var # create a directory for storing MySQL Databases

Chown-R mysql: mysql/usr/local/mysql/var # Set MySQL database Directory Permissions

Chown-R mysql: mysql/usr/local/mysql # Set MySQL database Directory Permissions

5: cd/usr/local/software # enter the Directory

 

----------------------- Compilation process -----------------------

6: tar-zxvf mysql-5.0.45.tar.gz # After decompression, a folder with the same name will appear in this directory

7: cd/usr/local/software/mysql-5.0.45

8:./configure -- prefix =/usr/local/mysql -- with-charset = utf8 -- with-collation = utf8_general_ci -- with-extra-charsets = latin1

Note (parameter description ):

-- Prefix =/usr/local/mysql => specifies the installation directory of mysql.

-- With-charset = utf8 => specify the default Character Set of mysql

-- With-collation = utf8_general_ci => specify the default Character Set of mysql

-- With-extra-charsets = latin1 => Add additional encoding. To save trouble, write all

9: make

10: make install

11: cp support-files/my-medium.cnf/etc/my. cnf # copy the configuration file. If/etc/my. cnf already exists, back up and delete it.

12: vi/etc/my. cnf # comment out log-bin = mysql-bin (disable binlog)

 

-------------------------- Install and configure mysql --------------------------

13: cd/usr/local/mysql

14: bin/mysql_install_db -- user = mysql -- datadir =/usr/local/mysql/var # install the system database

15: bin/mysqld_safe -- user = mysql & # Start the mysql Service

 

--------------------------------------- Change the root user password of mysql ----------------------------

16: bin/mysqladmin-uroot password 123456 # change the logon password of the root user when mysql is started normally

17: bin/mysql-uroot-p # after entering this command, you will be prompted to enter the root user password 123456

18: show databases; # If all databases are identified, the mysql database is successfully installed.

 

---------------------------------------------------- Add mysql to the System Service (start automatically )-------------------------------------

19: cp/usr/local/mysql/share/mysql. server/etc/init. d/mysqld

Chkconfig -- add mysqld # To the system service, you can manage it through service mysqld start | stop | status | restart, which is very convenient, you no longer need to start mysql at/usr/local/mysql5.0.45/bin.

Note: mysql. server ==> this script is mainly used to start and close the system in the system v-style running directory. It is usually installed under mysql. Mysql. server script calls mysqld_safe to start the server.

 

---------------------------------------------------------------- Configure the mysql environment variable ------------------------------------------------

20: cd/root # Go back to your personal home directory. I used root to log on here.

Cp. bashrc. bashrc. bak # back up

Vi. bashrc

Add: export PATH =/usr/local/mysql/bin: $ PATH :.

Source ~ /. Bashrc # Return to the terminal and enter this command to make the modification take effect ,~ Indicates the usage of the source command in the user's main directory: source FileName function: read and execute the command in FileName in the current bash environment.

Note: This command is usually replaced by the "." command. For example, source. bash_rc and. bash_rc are equivalent. Note: The difference between the source command and shell scripts is that the source command is executed in the current bash environment, and the scripts is to start a sub-shell to execute the command. In this way, if you write the commands for setting environment variables (or alias) into scripts, it will only affect the sub-shell and cannot change the current BASH. Therefore, through the file (command column) when setting environment variables, use the source command.

Env # check whether it is effective (display the existing environment variables in the System)

21: This is a method to replace steps 20.

Cp/usr/local/mysql/bin/mysql/usr/bin/mysql # Add the commonly used mysql tool directories to the system variable directories, and add them as needed, in this way, you can directly run the tool without switching to the directory, which is similar to adding environment variables.

 

------------------------------------------------------------------------------- Open port 3306 in Linux -------------------------------------------

22: service iptables stop # disable Firewall

Vi/etc/sysconfig/iptables # edit Firewall Configuration

-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT

Service iptables start # Enable Firewall

 

----------------------------------------------------------------------------- Enable the mysql remote access permission for the root user --------------------------------------------

23: shutdown-hr now # restart the VM.

Ps-ef | grep mysql # Check whether mysql is started with startup, or enter service mysqld status.

Mysql-uroot-p # Enter mysql and enter the password.

Grant all on *. * to root @ '%' identified by '000000'; # grant permission on database name. Table name to user @ login host identified by "User Password ";

Flush privileges; # For the convenience of development, the root user can have remote access permissions (% indicates allowing remote login)

# Finally, attach a very useful mysql client, http://download.csdn.net/source/924456

 

2. The default mysql database directory is/usr/local/mysql/var.

We specified the installation directory as/usr/local/mysql during installation. In addition to the files to be installed here, some users often use, the executable binary file is stored in/usr/bin. In fact, all these commands are available under/usr/local/mysql/bin, the command in/usr/bin is used for convenience. It is equivalent to setting the environment variable. You can echo $ PATH, it must have the value of/usr/bin. Understanding the installation process makes it hard to delete 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.