Chinaunix首页 | 论坛 | 博客
  • 博客访问: 81229
  • 博文数量: 12
  • 博客积分: 1560
  • 博客等级: 上尉
  • 技术积分: 146
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-07 07:23
文章分类
文章存档

2011年(2)

2010年(8)

2008年(2)

分类: Mysql/postgreSQL

2010-06-10 03:54:03

MYSQL版本:5.1.47 MySQL Community Server (GPL)
 
1.wget
 
将下载好的二进制安装包解压
tar zxvf msyql5.1.47
mv mysql5.1.47 /usr/local/
cd /usr/local
mv mysql5.1.47 mysql
添加mysql组,并且将mysql用户加入mysql组。
2.安装
如果用/usr/local/mysql/scripts/mysql_install_db --user=mysql
有可能会报如下错误:
FATAL ERROR: Could not find ./bin/my_print_defaults
If you are using a binary release, you must run this script from
within the directory the archive extracted into. If you compiled
MySQL yourself you must run 'make install' first.
解决办法:应指定安装路径,数据存放路径
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
3.设置目录访问权限
chown -R mysql /usr/local/mysql(所属mysql用户) 
chown -R mysql /usr/local/mysql/data(数据目录所属mysql用户)
4.启动测试
 /usr/local/mysql/bin/mysqld_safe --user=mysql &
 如果有类似提示
100610 02:42:28 mysqld_safe Logging to '/var/log/mysqld.log'.
100610 02:42:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
100610 02:42:29 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
因为mysql找不到可以读的文件/var/run/mysqld/mysqld.pid,查看之下,发现没有该目录
解决办法:
 mkdir /var/run/mysqld
 chown -R mysql /var/run/mysqld
 chgrp -R mysql /var/run/mysqld   
再次启动  /usr/local/mysql/bin/mysqld_safe --user=mysql &
提示成功
访问 /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.47 MySQL Community Server (GPL)
 
 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
说明已经安装成功
改个mysql的root用户密码吧
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET password=PASSWORD("xxx.com") WHERE user='root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 2  Changed: 1  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 
5.停止测试
 /usr/local/mysql/bin/mysqladmin shutdown
提示:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' !!!!!
竟然有这样的事情,原来pid文件是放在pid-file=/var/run/mysqld/mysqld.pid
不如做个软件链接吧:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
再次运行
/usr/local/mysql/bin/mysqladmin shutdown
提示
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user (using password: NO)'
是没有指定用户
 
/usr/local/mysql/bin/mysqladmin shutdown -u root -p
输入密码后
100610 04:16:19 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+  Done                    /usr/local/mysql/bin/mysqld_safe
mysql程序结束。
 
阅读(1635) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~