Installation of MySQL under Linux

Source: Internet
Author: User

First, install MySQL
1. Download the source package
Download the source package mysql-5.0.51b.tar.gz under Linux from the MySQL official website, and note that it is downloaded from the GNU tar format, not the RPM package.
2. Unpacking

Tar xvf mysql-5.0.51b.tar.gz

3. Go to MySQL Directory

CD mysql-5.0.51b

4. Installation

./configure--prefix=/opt/cuix/mysql-5.0.51 specifying the installation directory for MySQL
--with-charset=utf8 specifying a character set
--with-collation=utf8_general_ci
Make
Make install

Second, configure MySQL
1. Initialize the database
Executes the scripts/mysql_install_db, initializing the MySQL database authorization table, which stores the access permission of the server, which will create the Var directory under the MySQL installation directory.
2. Set path
For ease of use, add the Mysql-5.0.51/bin directory to the profile of the current user and then check with which MySQL for OK.
3. Setting MY.CNF configuration file
In the Support-files directory there are three pre-set files to choose from, choose a suitable for you, I choose here is my-medium.cnf, copy this file to your installation directory:

CP SUPPORT-FILES/MY-MEDIUM.CNF/OPT/CUIX/MYSQL-5.0.51/.MY.CNF

Note the use of MY.CNF, the path to this configuration file can be given through command line arguments when starting MySQL, such as:

./mysqld_safe--DEFAULTS-FILE=.MY.CNF &

4. Give my.conf permission

chmod 744. my.cnf

5. Modify the my.conf file
Find [Client]:
Add User=root,
Remove the comment before password and set the password for the root account.
Setting port, using Netstat–atln | grep "Port number" to see if your own port is occupied,
Change the socket, default/tmp/mysql.sock may conflict with other MySQL server, modify to the current MySQL installation directory.
Find [mysqld]:
Set port and socket,
Set Datadir=/opt/cuix/mysql-5.0.51/var
Add Default-character-set=utf8 to both client and mysqld

Third, run MySQL
1. Start MySQL
Enter the Mysql-5.0.37/bin directory (if Path is set), execute:

Mysqld_safe--DEFAULTS-FILE=/OPT/CUIX/MYSQL-5.0.51/.MY.CNF &

2. Check whether the installation is successful
Mysqladmin version will get the current MySQL release information
3. Log in to MySQL

Mysql-h 127.0.0.1-p 9906-u Root

4. Change the root password
The root account default password is empty, this must be modified, can be connected to the server after the execution:

Use MySQL;
Update user set Password=password (' New password ') where user= ' root ';
Flush privileges;

5. Add a new user
Add test, allow from localhost and telnet, password to "test"

GRANT all privileges on * * to [e-mail protected] identified by ' test ' with GRANT OPTION;
Grant all privileges on * * to [e-mail protected] "%" identified by ' test ' with GRANT OPTION;

The reason to use flush privileges when modifying an account with an SQL statement is to tell the server to reread the authorization table. Otherwise, changes will not be noticed until the server is restarted. With GRANT, you do not need to use flush privileges.
6. Turn off MySQL
Perform:

./mysqladmin-h localhost-p 3306-u root-p shutdown

By the end of the installation and configuration process, a MySQL shell file can be built in the user's root directory to facilitate the startup and shutdown of MySQL, as follows:

#!/bin/sh
Case $ in
Start)/opt/cuix/mysql-5.0.51/bin/mysqld_safe--DEFAULTS-FILE=/OPT/CUIX/MYSQL-5.0.51/.MY.CNF &;
Stop)/opt/cuix/mysql-5.0.51/bin/mysqladmin-h 10.3.2.36-p 9906-uroot-p shutdown;
Esac


This is done by./mysql Restart and./mysql stop to start and close MySQL.

Installation of MySQL under Linux

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.