Install MySQL in CentOS

Source: Internet
Author: User

CentOS, apache2.2.4, database Mysql-5.0.18. Use the mysql source package for installation, or use the mysql Binary Package or rpm package for installation.

1. Add a logon user and group:

# Groupadd mysql

# Useradd-g mysql

2. Decompress mysql-5.0.18.tar.gz to/usr/local/mysql

# Tar-zvxf mysql-5.0.18,tar.gz

3. Go to mysql-5.0.18 directory

# Cd mysql-5.0.18

4. Run configure to compile mysql source code

#./Configure -- prefix =/usr/local/mysql/

5. Install mysql to the specified directory

# Make; make install

6. Copy/support-files/my-medium.cnf to/etc/

# Cp./support-files/my-medium.cnf/etc/my. cnf

7. Before installing the mysql database, you must create an authorization table for mysql:

#/Scripts/mysql_install_db -- user = mysql &

Note: You can also use root, but -- user must be changed to-user.

8. Modify the permissions of the corresponding file (/usr/local/mysql /)

# Chown-R root/usr/local/mysql

# Chown-R mysql/usr/local/mysql

# Chown-R mysql/usr/local/mysql/var

9. Start mysql: (/usr/local/mysql /)

#./Bin/mysqld_safe -- user = mysql &

10. After installation, the root account password of the mysql database is blank by default. You can modify the password as follows:

#/Usr/local/mysql/bin/mysqladmin-u root-password 'new-password'

11. Add mysql commands to Environment Variables

# Echo "export PATH = $ PATH:/usr/local/mysql/bin">/etc/profile

# Source/etc/profile // make the environment variable take effect

# Echo $ PATH // output environment variable

/Usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin:/usr/X11R6/bin:/root/bin:/usr/local/mysql/bin
 

12. Start mysql at startup, and put mysql. server in the startup file/etc/init. d/mysql :(/usr/local/src/directory)

# Cp./mysql-5.0.18/support-fiels/mysql. server/etc/init. d/mysql

# Chkconfig -- add mysql

# Chkconfig mysql on

13. Log on to mysql: (you must add the mysql command to the environment variable)

# Mysql-u root-p12345
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 4 to server version: 5.0.18-log

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql> show databases;

+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Test |
+ -------------------- +
3 rows in set (0.02 sec)

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.