Linux下MySQL 5.5.8 源码编译安装记录分享
这篇文章主要为大家详细介绍了Linux下MySQL 5.5.8 源码编译安装记录分享,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!
系统:Ubuntu 10.10 mysql源码文件:mysql-5.5.8.tar.gz安装所需工具:cmake, GNU make, gcc, Perl, libncurses5-dev, bison(可选), chkconfig注:1.官方2010-11-18的源码有几处bug,在编译之前参照官方的说明,进行了手动修改。官方说明链接:http://lists.mysql.com/commits/1267822.官方5.5版本参考手册:http://dev.mysql.com/doc/汗了一下,3392页的参考手册!=>工具安装:1. cmake----没有自己编译安装cmake----shell:~$ sudo apt-get install cmake----版本:2.8.22. GNU make----Ubuntu自带----版本:3.813.GCC----Ubuntu自带----版本:4.4.5(官方文档:必须3.2以上)4.Perl----Ubuntu自带----版本:5.10.15.libncurses5-dev (ncurses-devel)----若差了这个包,在cmake的时候会报错。----Debian/Ubuntu上的包名是libncurses5-dev,RedHat和其他版本对应的是ncurses-devel----shell:~$ sudo apt-get install libncurses5-dev----报错信息------------------www.linuxidc.com----------------- MySQL 5.5.8-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)CMake Error at cmake/readline.cmake:82 (MESSAGE):Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu , package name is libncurses5-dev ,on RedHat and derivates it is ncurses-devel.Call Stack (most recent call first):cmake/readline.cmake:126 (FIND_CURSES)cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)CMakeLists.txt:256 (MYSQL_CHECK_READLINE)-- Configuring incomplete, errors occurred!---------------------------------6. bison----shell:~$ sudo apt-get install bison----可选。没有这个工具,在make的时候报出警告。----警告记录:---------------------------------Warning: Bison executables not found in PATH---------------------------------7.chkconfig----后面配置mysql服务自启动的时候需要。----shell:~$ sudo apt-get install chkconfig=>mysql安装:1.解压源代码文件----shell定位到源代码文件所在目录----解压shell:~$ tar zxvf mysql-5.5.8.tar.gz2.cmake操作----shell定位到解压出的源代码文件夹目录(文件夹:mysql-5.5.8)----cmake执行:---------------------------------shell:~$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/home/system_username/Programming/mysql/mysqldata-DSYSCONFDIR=/etc-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock-DMYSQL_TCP_PORT=3306-DENABLED_LOCAL_INFILE=1-DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8-general_ci-DMYSQL_USER=mysql注:没有换行。官方文档上,cmake 命令后面加个点不懂什么意思。在这里加上命令执行不了---------------------------------源代码配置选项说明://mysql安装的主目录,5.5.8版本默认为/usr/local/mysql,所以可以不添加-DCMAKE_INSTALL_PREFIX=/usr/local/mysql//mysql数据保存的路径,自定义-DMYSQL_DATADIR=/home/system_username/mysql/mysqldata//mysql配置文件地址------The default my.cnf option file directory-DSYSCONFDIR=/etc//Compile storage engine xxx statically into server/*Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server)*or a dynamic module (built as a dynamic library that must be installed into the server using the INSTALL*PLUGIN statement or the --plugin-load option before it can be used). Some plugins might not support static*or dynamic building.*/-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1//Unix socket file/**The Unix socket file path on which the server listens for socket connections. This must be an absolute path*name. The default is /tmp/mysql.sock*/-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock//数据库服务器TCP/IP连接的监听端口,默认为3306-DMYSQL_TCP_PORT=3306//Whether to enable LOCAL capability in the client library for LOAD DATA INFILE//默认为关闭,这里开启-DENABLED_LOCAL_INFILE=1//数据库编码设置-DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8-general_ci3.编译和安装----shell定位到源代码文件夹目录----执行:(编译用了大概20分钟)shell:~$ makeshell:~$ make install4.后续配置----进入mysql安装目录下的脚本目录shell:~$ cd /usr/local/mysql/scripts----利用mysql_install_db脚本生成新的MySQL 授权表./mysql_install_db --basedir=/usr/local/mysql --datadir=/home/system_username/Programming/mysql/mysqldata--user=mysql----进入mysql安装目录下的支持文件目录shell:~$ cd /usr/local/mysql/support-files----复制mysql配置文件shell:~$ sudo cp my-medium.cnf /etc/my.cnf----复制服务文件并修改shell:~$ sudo cp mysql.server mysqld----修改mysqldbasedir=/usr/local/mysqldatadir=/home/mysqlmv mysqld /etc/init.d/mysqld----启动服务shell:~$ service mysqld start----关闭服务shell:~$ service mysqld stop---------------------------------service命令:1. 用于管理Linux系统中服务的命令2. 作用是去/etc/init.d目录下寻找相应的服务,进行开启和关闭等操作3. 上述操作后,mysqld服务文件对应mysql.server文件-------------------------------------添加服务到自启动项shell:~$ sudo chkconfig --level 3 mysqld on----设置软连接使mysql, mysqldump, mysqladmin这三个命令能在shell中直接运行shell:~$ sudo ln -s /usr/local/mysql/bin/mysql /usr/binshell:~$ sudo ln -s /usr/local/mysql/bin/mysqldump /usr/binshell:~$ sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin---------------------------------=>mysql数据库中文乱码解决 :1. 乱码分析----从终端shell进入mysqlshell:~$ mysql........................mysql> show variables like '%character%'----得到以下数据库编码信息表:+----------------------------------- +-------------------------------------------+| Variable_name | Value |+------------------------------------+-------------------------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | latin1 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | latin1 || character_set_system | utf8 || character_sets_dir | /usr/local/mysql/share/charsets/ |+------------------------------------ +-------------------------------------------+可以看出character_set_database ,character_set_server 的编码还是默认的latin1。不知道为什么,之前DEFAULT_CHARSET设置成为utf8的,好像没起作用。查看官方文档发现,character_set_database不支持配置文件(/etc/my.cnf)变量设置,但是character_set_server 支持配置文件变量设置。2. 解决办法----打开配置文件shell:~$ sudo gedit /etc/my.cnf然后在[mysqld]配置选项下添加character-set-server = utf8----然后进入mysql执行:mysql> show variables like '%character%'结果:character_set_database ,character_set_server两项都变为utf8了----测试:往数据库表中插入中文字段,中文就正常显示了。注:1.用5.1版本的时候如下方法是可以解决中文编码问题的----在配置文件[mysqld]和[client]节下分别添加: default-character-set = utf82.不知到是不是手动编译的原因,在5.5.8中配置文件中用上述方法会造成数据库服务无法启动。----错误日志如下:( datadir/username.err为错误日志文件)----------------------------------------------------mysqld_safe mysqld from pid file /home/cyberwym/Programming/mysql/mysqldata/cyberwym.pid ended......................[ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'default-character-set=utf8'[ERROR] Aborting--------------------------------------------------------这样会造成pid文件(datadir/username.pid)无法更新----在配置文件[mysqld]和[client]节下分别去掉: default-character-set = utf8 后,数据库服务就启动正常了
注:关于Linux下MySQL 5.5.8 源码编译安装记录分享的内容就先介绍到这里,更多相关文章的可以留意