MySQL installation and configuration method under Freebsd7.0

Source: Internet
Author: User

Install ports first, recommend ports is up to date, not up to date, can be updated with Portsnap,cvsup,portmanager or Portupgrade tools

Prepare =======================================================

The code is as follows Copy Code

#cd/usr/ports/databases/mysql50-server
#pwd
#make//Time is long

#make Install//installation

#make clean//clear temporary files generated during installation to save hard disk space

Or use the combination of the above three commands:

The code is as follows Copy Code
#make with_xcharset=all With-charset=utf8 with_proc_scope_pth=yes skip_dns_check=yes BUILD_OPTIMIZED=yes Install Clean

Install ============================================

The code is as follows Copy Code
#cd/usr/ports/databases/mysql50-server
#pwd
#make

Configure ============================================

-R contains all directories and files under the directory

The code is as follows Copy Code

#mysql_install_db
#chown-R Mysql/var/db/mysql
#chgrp-R Mysql/var/db/mysql

#/usr/local/bin/mysqld_safe--user=mysql &//Use & to enable in the background to facilitate the detection process is normal

Check Installation ============================================

The code is as follows Copy Code

#ps-ef|grep mysqld

#netstat-an | grep 3306 Detection
#mysql//Connection MySQL
#show databases//

Advanced Configuration ============================================

The code is as follows Copy Code

Set to system enable service
#echo ' mysql_enable= ' yes ' >>/etc/rc.conf

MySQL optimization ============================================

The code is as follows Copy Code

MySQL optimization
#ls/usr/local/share/mysql/*.cnf
#cp/usr/local/share/mysql/my-medium.cnf/var/db/mysql/my.cnf


The following is an introduction to installing the MySQL 5.0.51a tutorial

1, go to freebsd.org download the appropriate installation package (packages):

The code is as follows Copy Code

ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/
Devel/libtool-1.5.24.tbz
ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/
Databases/mysql-client-5.0.51a.tbz
ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/
Databases/mysql-server-5.0.51a.tbz

2, install the three files downloaded above to the same directory, and execute the following command for installation:

The code is as follows Copy Code

Cd/var/ftp/incoming
Pkg_add MYSQL-SERVER-5.0.51A.TBZ

3, prompts the installation completes, then executes:

The code is as follows Copy Code

/usr/local/bin/mysql_install_db--user=mysql

4, start MySQL:

The code is as follows Copy Code

/usr/local/bin/mysqld_safe--user=mysql &

5, modify the MySQL password:

The code is as follows Copy Code

/usr/local/bin/mysqladmin-u root password ' 123456789 '

Or

/usr/local/bin/mysqladmin-u root-h Demo.localdomain
Password ' 123456789 '

The root password is empty at the initial installation time. If the user root has an old password, the password is prompted to enter.

6, test for startup success on another computer:

Telnet 192.168.232.129 3306

An error message appears:
Fhost ' 192.168.232.1′is not allowed to connect to this MySQL server
Solution:

The code is as follows Copy Code

/usr/local/bin/mysql-u root-p
Enter the password and enter the MySQL management console:
Mysql> GRANT all privileges in *.* to ' root ' @ '% ' identified
By ' 123456789 ' with GRANT OPTION;

The principle is: Allow all users with root and enter the root password to log into the MySQL Server,
If you change '% ' to ' 10.1.1.1′ ' then only 10.1.1.1 of the host can log in.

7, automatically start MySQL:

The code is as follows Copy Code

ee/usr/local/etc/rc.d/mysql_start.sh
/usr/local/bin/mysqld_safe--user=mysql &

Press CTRL + Save file
Perform:

The code is as follows Copy Code

chmod +x/usr/local/etc/rc.d/mysql_start.sh

Complete the MySQL installation and start from.

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.