FreeBSD installation MySQL

Source: Internet
Author: User

1. FreeBSD this system to tell the truth really does not have Ubuntu convenience, to install a software, Apt-get install under can be, and in FreeBSD under the ports down only in the installation, but usually there is no resources, pit AH
So I can only put my own bag.


1. First down mysql-5.1.70.tar.gz

TAR-ZXVF mysql-5.1.70.tar.gz
CD mysql-5.1.70
./configure--prefix=/usr/local/mysql
Make With_charset=utf8 with_proc_scope_pth=yes build_optimized=yes build_static=yes SKIP_DNS_CHECK=yes WITHOUT_ Innodb=yes Install clean

pw groupadd MySQL

pw useradd mysql-g mysql

/usr/local/mysql/bin/mysql_install_db--user=mysql
cp/usr/local/mysql/share/mysql/my-large.cnf/etc/my.cnf
Cd/usr/local/mysql

chown-r root.
Chown-r mysql var
chown-r mysql var/mysql/.

chgrp-r MySQL. # # Don't forget to write #
/usr/local/mysql/bin/mysql_install_db--user=mysql
./mysqld_safe--user=mysql &
//installed after the initial password is notReset Password./mysqladmin-uroot-p Password 123456You will be prompted to enter password: Press the ENTER key directly (here to lose the original password, the original password did not)
start MySQL[email protected]:/usr/local/mysql/bin #./mysqld_safe--user=mysql &
turn off MySQL [email protected]:/usr/local/mysql/bin #/mysqladmin-uroot-p shutdown

go to MySQL[email protected]:/usr/local/mysql/bin #./mysql-u root-p
when you use Navicate to connect, turn on permissions.[email protected]:/usr/local/mysql/bin #./mysql-u root-pmysql> GRANT All privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT option;mysql> FLUSH privileges;mysql> EXIT
Write segment code under test
#include <iostream> #include <string.h> #include "mysql.h"//installed MySQL header files are located at the location using namespace std;string Host = "192.168.67.130"; string user = "root"; string pwd = "123456"; string dbname = "Test"; String sql = "SELECT * from user "; unsigned int port = 3306; int Status;int Main () {MYSQL *mysql;mysql = mysql_init (0); Mysql_res *result; Mysql_row row;if (Mysql_real_connect (MySQL, Host.c_str (), User.c_str (), Pwd.c_str (), Dbname.c_str (), Port, NULL, CLIENT _found_rows) = = NULL) {cout << "connect failure!" << Endl;return exit_failure;} Else{cout << "Connect success!" << Endl;} Mysql_set_character_set (MySQL, "GBK"); status = mysql_query (MySQL, sql.c_str ()); if (status! = 0) {cout << "query failure! "<< Endl;} cout << "The status is:" << status << endl;result = Mysql_store_result (MySQL), while (row = Mysql_fetch_ Row (Result) {cout << row[1] << "|" << row[2] << Endl;} Mysql_free_result (result); Mysql_close (MySQL);}

g++-o testmysql testmysql.cpp-lmysqlclient-i/usr/local/mysql/include/mysql-l/usr/local/mysql/lib/mysql/

compile can succeed, but execute./testmysqlprompt for the following error Shared Object "libmysqlclient.so.16" not found, required by "Testmysql"

should be inside the code link path is not correct, but there is no way to change the code, can only change the path
[email protected]:/usr/local/mysql/lib/mysql # Ln-s Libmysqlclient.so.16/usr/lib/libmysqlclient.so[email protected]:/usr/local/mysql/lib/mysql # CP Libmysqlclient.so.16/usr/lib
so you can, the big confession, write down, lest later forget again



FreeBSD installation MySQL

Related Article

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.