显示标签为“mysql”的博文。显示所有博文
显示标签为“mysql”的博文。显示所有博文

2012年7月6日星期五

在debian squeeze上编译安装mysql-5.5.24

由于mysql-5.5已经发布,为了观察mysql-5.5的性能如何,这次决定在deiban上使用mysql-5.5.24,但debian源上并没有mysql-5.5,因此需要编译安装。

准备
首先去下载mysql-5.5.24

另外从源码编译mysql-5.5.24还需要安装以下包:
aptitute install cmake make gcc g++ ncurses-dev

编译及安装
解压源码包:
tar xvf mysql-5.5.24.tar.gz && cd mysql-5.5.24

编译及安装:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.24 && make && make install

后续操作
添加用户和用户组并修改属主:
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local/mysql-5.5.24
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .

参考
源码包中的INSTALL-SOURCE关于安装mysql需要的软件:
Source Installation System Requirements

   Installation of MySQL from source requires several development
   tools. Some of these tools are needed no matter whether you use a
   standard source distribution or a development source tree. Other
   tool requirements depend on which installation method you use.

   To install MySQL from source, your system must have the following
   tools, regardless of installation method:

     * CMake, which is used as the build framework on all platforms.
       CMake can be downloaded from http://www.cmake.org.

     * A good make program. Although some platforms come with their
       own make implementations, it is highly recommended that you
       use GNU make 3.75 or newer. It may already be available on
       your system as gmake. GNU make is available from
       http://www.gnu.org/software/make/.

     * A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 10
       or later, Visual Studio 2008 or later, and many current
       vendor-supplied compilers are known to work.

     * Perl is needed if you intend to run test scripts. Most
       Unix-like systems include Perl. On Windows, you can use a
       version such as ActiveState Perl.
源码包中INSTALL-SOURCE关于mysql的相关操作步骤:
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

2010年4月23日星期五

mysql忘记密码的解决方法

很久之前装了mysql,今天突然要用到,但是密码(包括root用户的)都忘掉了。那怎么办呢?google了一下,原来mysql的开发者早已考虑到这点。
解决方法:
1. 以root用户身份运行
#mysqld_safe --skip-grant-tables
2. 如果上面的命令正确运行的话,那么现在进入mysql是不用输入密码的,于是以root身份进入mysql并修改在mysql数据库user表中的密码
#mysql -uroot mysql
或者用有权限更改mysql的用户登录
mysql>update user set password=password("your new password") where user="root";
//这里也可以修改其它用户的密码
mysql>flush privileges;
3. 到此,用户密码已经修改成功了。然后就kill掉mysql的进程并重新运行mysql的后台进程。

呵呵,用mysql还是挺方便的,希望mysql能继续下去啦。

2010年3月17日星期三

Mysql远程连接

GRANT privileges (columns) ONwhat TO user IDENTIFIED BY "password"