mysql 编译安装



==========================================================================

新建用户和用户组


[root@centos ]#groupadd mysql

[root@centos ]#useradd -g mysql mysql


安装编译工具:

bison

cmake

make

bzr

autoconf

automake

ncurses-devel

mysql-5.6.12.tar.bz2


[root@centos ]#yum install bison cmake make bzr autoconf automake ncurses-devel


[root@centos ]#tar jzxf mysql-5.6.12.tar.bz2 -C /usr/src

[root@centos ]#cd /usr/src/mysql-5.6.12

[root@centos ]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data/ \

-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=/usr/local/mysql/mysqld.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DMYSQL_USER=mysql


//参数参考:http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html


[root@centos ]#make && make install

--------------------------------------------------------------------------------

修改权限:

[root@centos ]#chown mysql:mysql /etc/my.cnf

[root@centos ]#chown -R mysql:mysql /usr/local/mysql/mysqldir


修改配置文件:

[root@centos ]#vim /etc/my.cnf

   序号18 basedir = /usr/local/mysql/mysqldir

19 datadir = /usr/local/mysql/mysqldir/data

20 port = 3306

21 server_id = 1

22 socket = /usr/local/mysql/mysqld.sock


创建系统数据库的表:

[root@centos ]#/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql


添加系统服务

[root@centos ]#cp support-files/mysql.server /etc/init.d/mysqld  

[root@centos ]#vim /etc/init.d/mysqld

46 basedir==/usr/local/mysql/mysqldir

47 datadir=/usr/local/mysql/mysqldir/data

[root@centos ]#chkconfig --add mysqld

[root@centos ]#chkconfig mysql on

[root@centos ]#service mysqld start



设置环境变量

[root@centos ]#vim ~/.bash_profile

第10行 PATH=$PATH:$HOME/bin:/usr/local/mysql/mysqldir/bin


登陆mysql:

[root@centos ]#cd /usr/local/mysql/mysqldir/bin

[root@centos ]#./mysqladmin -u root password '123456' //设置root用户密码为123456

[root@centos ]#./mysql -u root -p     (提示输入密码后登陆成功)

[root@centos ]#

==========================================================================

出错:

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!


缺少包:ncurses-devel

解决:

[root@centos ]#yum install ncurses-devel

[root@centos ]#rm -f CMakeCache.txt   (前面已安装但仍出问题直接执行这句)



==========================================================================

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock



解决1:mysql -u 你的mysql用户名 -p -S /usr/local/mysql/mysqldir/mysql.sock  (my.cnf中socket目录)

解决2:my.cnf中改为socket =/tmp/mysql.sock


==========================================================================

my.conf配置详解

http://www.cnblogs.com/toby/articles/2198697.html



==========================================================================

mysql允许远程连接


[root@centos ]/usr/local/mysql/mysqldir/bin/mysql -u root -p  (进入mysql)  

mysql>use mysql;  

mysql>SELECT `Host`,`User` FROM user;  

mysql>UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;  

mysql>flush privileges;  



==========================================================================




==========================================================================




==========================================================================


你可能感兴趣的:(mysql,mysql编译安装)