Install MySql in Linux

Source: Internet
Author: User

Install mysql5.0 in Linux

 

In the installation and configuration process of mysql5.0 under suse9, because the source code package is used for installation, this process should also apply to other versions of Linux.

1. Install MySQL
1. Download the source code package
Download the sourcepackage mysql-5.0.51b.tar.gz from mysql. Note that the GNU Tar format is downloaded, not the RPM package.
2. Unpack

Tar xvf mysql-5.0.51b.tar.gz


3. Enter the MySQL directory

CD mysql-5.0.51b

4. Installation

./Configure -- prefix =/opt/cuix/mysql-5.0.51 specifies the installation directory for MySQL
-- With-charset = utf8 specifies the character set
-- With-collation = utf8_general_ci
Make
Make install

 

Ii. Configure MySQL
1. initialize the database
Execute scripts/mysql_install_db to initialize the MySQL database authorization table, which stores the server access permission. This operation 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 use which MySQL to check if OK.
3. Set the my. CNF configuration file.
There are three pre-set files to choose from under the support-Files directory, choose one for you, and here I choose 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 usage of my. CNF. The path of this configuration file can be given through the command line parameter at MySQL startup, for example:

./Mysqld_safe -- defaults-file =. My. CNF &

4. grant permissions to my. conf

Chmod 744. My. CNF

5. Modify the my. conf file
Find [client]:
Add User = root,
Remove the comment before the password and set the password for the root account,
Set the port and use netstat-atln | grep "port number" to check whether your port is occupied,
Change the socket. The default/tmp/MySQL. Sock may conflict with other MySQL servers and be changed 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 client and mysqld

Iii. Run MySQL
1. Start MySQL
Go to the mysql-5.0.37/bin directory (not required if path is set) and run:

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 version information
3. log on to MySQL

Mysql-H127.0.0.1-P9906-U Root

4. Modify the root password
The default password of the root account is null. You must modify the password. After connecting to the server, run the following command:

Use MySQL;
Update user SET Password = PASSWORD ('new password') where user = 'root ';
Flush privileges;


5. Add a new user
Add test to allow remote logon from localhost. The password is "test"

Grant all privileges on *. * To test @ localhost identified by 'test' with grant option;
Grant all privileges on *. * To test @ "%" identified by 'test' with grant option;

The reason why flush privileges is used when an account is modified using an SQL statement is to tell the server to re-read the authorization table. Otherwise, the changes will only be noticed after the server is restarted. If you use Grant, you do not need to use flush privileges.
6. Disable MySQL
Run:

./Mysqladmin-H localhost-P3306-U root-P Shutdown

The installation and configuration process ends. You can create a MySQL shell file under the user root directory to enable and disable MySQL, as shown below:

#! /Bin/sh
Case $1 in
Start)/opt/cuix/mysql-5.0.51/bin/mysqld_safe -- defaults-file =/opt/cuix/mysql-5.0.51/. My. CNF &;;

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.