Install MySQL 5.22 in Linux

Source: Internet
Author: User
Body: MySQL version: 5.0.22 (you can download a new version from the mysql.cn Chinese site)

In fact, MySQL is just a software in Linux... it's no big deal. It's like installing a CS server in your computer... it's only used to provide SQL services.

In fact, the entire installation process is not complex ,~ However, many Internet users have said that they cannot use it after they have installed it .. it's because the subtle things are not properly tuned .. this note records my entire national day study on installing MySql in Linux. Why can't I solve the problem.

Let's talk about the well-known installation methods.

Download mysql-5.0.22-2.1.i386.tar and MySQL-Devel-5.0.22-2.1.i386.rpm installation package (remember to install devel at the beginning. Many installation packages depend on MySQL. h; otherwise, the installation will not be discussed later ).

Then the tar-zxvf mysql-5.0.22-2.1.i386.tar (that is, extract)

Then enter the decompressed directory CD MySQL mysql-5.0.22-2.1.i386

Then, run./configure -- prefix =/usr/local/MySQL -- sysconfdir =/etc -- localstatedir =/var/lib/MySQL.

Note:

# Prefix =/usr/local/MySQL target directory for MySQL Installation

# Sysconfdir =/etc my. ini configuration file path

# Localstatedir =/var/lib/MySQL database storage path

Wait for several minutes ~ Make ~

Make this stuff... for the MySQL source package, it is simply... the CPU of this test server is piII 1G ~ I waited for half an hour.

Then, in half an hour ~~ Just make install... and wait for a few minutes. Then, even if MySQL is installed, you can start to make minor things below.

Initialize the database after installation:

/Usr/local/MySQL/bin/mysql_install_db

If the system does not have a MySQL user, do the following:

Useradd-M-o-r-D/var/lib/MySQL-S/bin/bash-c "MySQL Server"-U 27 MySQL

Then I start MySQL.CodeIs very important. Remember to add the execution user -- user = xxx)

/Usr/local/MySQL/bin/mysqld_safe -- user = root & or -- user = MySQL &

OK. Check if MySQL works properly.

Generally, the database cannot be connected normally. The error message is:

Error 2002: Can't connect to local MySQL server through socket '/var/lib/MySQL. Sock' (2)

In fact, most of the questions on the Internet are the whole question. If you cannot find any link to mysqld. Sock, you may wish to see the MySQL error log to understand what is going on. Here, the error log is

/Var/lib/MySQL /*. err, you will find that MySQL cannot be started only because/var/lib/MySQL does not allow access to the MySQL service. By default, MySQL calls the MySQL user to start the service, since you know why it cannot be started, it's easy. As long

Chown-r MYSQL: MySQL/var/lib/MySQL. If it still cannot be started, you can debug the permission slowly. Generally, it is a permission issue if it cannot be started. Or what directory is missing... remember to check the/var/lib/MySQL/*. Err error log, which will tell you where the error is.

If you still cannot start it, use my complicated permission settings. I do this every time. Generally, there is no problem. See:

Chown-r root/usr/local/MySQL
Chgrp-r MySQL/usr/local/MySQL
Chown-r root/usr/local/MySQL/bin
Chgrp-r MySQL/usr/local/MySQL/bin
Chgrp-r MySQL/var/lib/MySQL
Chmod 777/var/lib/MySQL
Chown-r root/var/lib/MySQL
Chgrp-r MySQL/var/lib/MySQL
Chmod 777/var/lib/MySQL
Chown-r root/var/lib/MySQL /*
Chgrp-r MySQL/var/lib/MySQL /*
Chmod 777/var/lib/MySQL /*
Chmod 777/usr/local/MySQL/lib/MySQL/libmysqlclient.

After completing the preceding steps, run/usr/local/MySQL/bin/mysqld_safe -- user = root &

No such thing as end... it proves that MySQL runs successfully ..

Run the PORT command to verify netstat-ant ~~ Port 3306 is displayed, indicating that it is successful!

Then copy a script in your compiled directory

CP support-files/MySQL. Server/etc/rc. d/init. d/mysqld

Chkconfig -- add mysqld

Set ntsysv to enable MySQL to run automatically at each startup.

But !, Many netizens often find that MySQL cannot be automatically started when they restart the server.

When you run etc/rc. d/init. d/mysqld start... [failure]

Run/usr/local/MySQL/bin/mysqld_safe -- user = root.

Why ?? This is why I have been depressed for so long !!.. Originally, the. Linux as4 version has strict permission requirements !!.. The account MySQL we just created is not running.ProgramAnd etc/rc. d/init. d/mysqld start, which is the default execution user of MySQL.

So it cannot be started .~ If you are running

Run/usr/local/MySQL/bin/mysqld_safe -- user = MySQL & not -- user = root.

So !... Add the MySQL user to the root group while in the MySQL group .~ That is to say, it has the root permission to execute the program.

Run etc/rc. d/init. d/mysqld start again ~~ Hey! Success !..

Try restarting ~~ After the machine is started, enter netstat-ant !.. Hey hey !~.. 3306 is displayed!

/Usr/local/MySQL/bin/mysqladmin-u root-P password 'mysql root password'

Run the preceding command to modify the MySQL password ~

Now MySQL has been installed.

 

Note that when we install some mysql-dependent packages in the source code, the system prompts cannot find MySQL header files. This is because the development version is not installed or the path is not specified correctly,

    • Generally, you need to find it first.

Find/-name mysql. h

    • Install mysql if it cannot be found-Devel-5.0.22-2.1.i386.rpm installation package (remember to install devel at the beginning. Many installation packages depend on MySQL. h; otherwise, the installation will not be discussed later ).

Rpm-IVH mysql-Devel-5.0.22-2.1.i386.rpm

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.