FreeBSD version is 7.3,mysql version is 5.0.90,apache version is 2.2.14 (1.3.42), PHP version is 5.2.12. The order of my installation is MySQL first, then install Apache and PHP, is usually installed to complete a and test after the installation of the next, so easy to find the problem.
One. Installing MySQL
The code is as follows |
Copy Code |
cd/usr/ports/databases/mysql50-server/ Make With_xcharset=all//default support for all character sets Make install
|
# After a long download and compile process, MySQL basic installation is complete.
The code is as follows |
Copy Code |
Rehash
|
# copy MySQL configuration file, the system defaults to provide four, according to the server's configuration to select the appropriate configuration file, most of the MySQL configuration # can be done through this configuration file, you can also view the various configuration information of the database in this profile.
The code is as follows |
Copy Code |
Cp/usr/local/share/mysql/my-large.cnf/etc/my.cnf
|
# edit rc.conf file, add mysql_enable= ' YES ' in it
The code is as follows |
Copy Code |
Vi/etc/rc.conf |
# Start MySQL
The code is as follows |
Copy Code |
cd/usr/local/etc/rc.d/ ./mysql-server.sh Start |
# Start the MySQL client
The code is as follows |
Copy Code |
Cd/usr/local/bin ./mysql–u Root-p
|
If you can successfully connect to MySQL, it means the installation is successful!
a few things to note:
The parameters at make installation
The code is as follows |
Copy Code |
With_xcharset=all will not support GBK encoding without this. Build_optimized=yes Build_static=yes |
These 2 items are all optimized, plus good
MySQL defaults to read the MY.CNF under the/etc directory, but the installation process does not automatically create this file in this directory, the default file is under the/usr/local/share/mysql directory, there are 3 versions:
MY-LARGE.CNF general high Configuration server or MySQL dedicated server with this configuration file
MY-MEDIUM.CNF server configuration and running for other applications use this profile
MY-SMALL.CNF server resources It's okay to use this.
Depending on your machine configuration, select a
The code is as follows |
Copy Code |
Cp/usr/local/share/mysql/my-large.cnf/etc/my.cnf
|
The installation process does not automatically create a default database, which you need to create manually
The code is as follows |
Copy Code |
/usr/local/bin/mysql_install_db–user=mysql
|
And you need to change the permissions on the database directory, or it won't start.
The code is as follows |
Copy Code |
Chown-r Mysql:mysql/var/db/mysql
|
Start MySQL, as if the first time to start with a script to use
The code is as follows |
Copy Code |
/usr/local/etc/rc.d/mysql-server OneStart
|
You can't use/usr/local/etc/rc.d/mysql-server start.
Modify the root password, such as we want to modify to 123456
The code is as follows |
Copy Code |
Mysqladmin-uroot-p Password 123456
|
You will be prompted to enter the password again enter password:, and then enter a 123456 can be (fising Note: This should be the original old password, rather than confirm the new password)
Modify the default directory for data files
VI/ETC/MY.CNF Add the datadir= database directory, remember to copy the original/var/db/mysql files in the past, and then execute
Directory of Chown-r Mysql:mysql databases
The last thing you should never forget is that MySQL can't start again.
Modify the Mysql_dbdir= "/var/db/mysql" in the/usr/local/etc/rc.d/mysql-server file for your new directory
or add mysql_dbdir= "new directory" to/etc/rc.conf
Finally, join mysql_enable= "yes" in/etc/rc.conf to let MySQL boot from