免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: wypdao
打印 上一主题 下一主题

linux下非root用户安装mysql的问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2006-03-31 23:08 |只看该作者
先谢谢各位的 帮助 ,但是我的问题还没解决,我 在命令行里运行mysql提示如下错误:

ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

我在google上搜索这个错误,提示好象是服务未启动,我又运行./mysql.server start 又出如下错误

Starting MySQLCouldn't find MySQL manager or server        [失败]

附:to  8楼的 大哥,方便的话告诉我您下载mysql完整的版本号,我看看是不是我 的版本的问题,

如果您还有时间的话麻烦您给我简短写个教程,就是先运行什么,再运行什么,只要数据库能正常工作就行,我们以前都用oracle数据库,现在刚接触mysql,不是很熟练,

再次感谢各位的帮忙!!!!

论坛徽章:
0
12 [报告]
发表于 2006-03-31 23:36 |只看该作者
我又在本论坛的FAQ里看到如下方法:
**********************************************************************************
Q: 如何安装已经编译好了的mysql二进制包
A:
CODE:
[Copy to clipboard]
首先下载合适的二进制包,例如下载了文件 mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz
#groupadd mysql
#useradd -g mysql mysql
#cd /usr/local
#tar zxf mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz
#ln -s mysql-standard-4.1.13-pc-linux-gnu-i686 mysql
#cd mysql
#scripts/mysql_install_db --user=mysql
#chgrp -R mysql *
#bin/mysqld_safe --user=mysql &
有什么个性化的配置,可以通过创建 /etc/my.cnf 或者 /usr/local/mysql/data/my.cnf,增加相关的参数来实现。
*************************************************************************************

自己执行了一下mysql_install_db,出现如下错误:

mkdir: 无法创建目录‘/var/lib/mysql/mysql’: 权限不够
chmod: 无法取得 ‘/var/lib/mysql/mysql’ 的属性: 没有那个文件或目录
mkdir: 无法创建目录‘/var/lib/mysql/test’: 权限不够
chmod: 无法取得 ‘/var/lib/mysql/test’ 的属性: 没有那个文件或目录
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
ERROR: 1049  Unknown database 'mysql'
060331 23:21:07  Aborting

060331 23:21:07  /usr/libexec/mysqld: Shutdown Complete

Installation of grant tables failed!

Examine the logs in /var/lib/mysql for more information.
You can also try to start the mysqld daemon with:
/usr/libexec/mysqld --skip-grant &
You can use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:

shell> /usr/bin/mysql -u root mysql
mysql> show tables

Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.

The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!


感觉还是得给/var/lib/mysql里写东西,我可不可以把这个默认路径改调啊,如何修改,还请各位再给出出主意,
谢谢!!!!

论坛徽章:
0
13 [报告]
发表于 2006-04-01 11:42 |只看该作者
注:以下都是在普通账号权限下执行,假设账号是 rardge,组也是 rardge。
1. 用 cd 指令切换到你自己的用户目录;
2. 下载合适的二进制包,例如下载了文件 mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz <-- 这个自己去下载,我是freebsd系统,我下的是最新的5.x的,你是linux,我不知道你该用哪个。但原理应该一样。
3. tar xzvf 刚才下的包
4. mv 解压后的目录名 mysql <-- 改名字只是为了输入起来方便,不用输入一长串东西。
5. 设置访问权限,重要!
  chown -R rardge:rardge mysql <-- 让 rardge 对 mysql 目录可读写
  chmod -R o= mysql <-- 除了 rardge 和 root 外,无人能访问 mysql 目录(这个是在上面假设的前提下,注意你的用户组,如果组里面有其他成员,你还要再 chmod -R g= mysql)
  ls -ld mysql 看看权限 rwxr-x--- 或者 rwx------
6. cd mysql
7. ./scripts/mysql_install_db --user=rardge <-- 如果你当前登录账号和后面这个参数中指定的一样的,也可以不加那个参数,关键是用一个可以对 mysql 目录有 写 权限的账号!
8. 启动
  ./bin/mysqld_safe --user=rardge &

如果没错的话,再设置 MySQL 的 root 口令,就 Ok 了!
另,我的系统和你的不一样,所以有些差异你自己掌握。

至于你说的'/var/lib/mysql/mysql',这个在 mysql_install_db 中可以修改。
你搜索一下 ldata,它可能是 ldata=/var/lib/mysql 这样,你改成 ldata=./data,意思是数据库放在你 mysql 目录下的 data 目录,这个你肯定有写权限了。

[ 本帖最后由 rardge 于 2006-4-1 11:46 编辑 ]

论坛徽章:
0
14 [报告]
发表于 2006-04-01 16:22 |只看该作者
再次感谢rardge的答复,但是问题还是没有解决,我打开mysql_install_db,内容如下:

1:#!/bin/sh
2:# Copyright (C) 2002-2003 MySQL AB
3:# For a more info consult the file COPYRIGHT distributed with this file.
4:
5:# This scripts creates the privilege tables db, host, user, tables_priv,
6:# columns_priv, procs_priv in the mysql database, as well as the func table.
7:#
8:# All unrecognized arguments to this script are passed to mysqld.
9:
10:in_rpm=0
11:windows=0
12:defaults=""
13:user=""
14:
15:case "$1" in
16:    --no-defaults|--defaults-file=*|--defaults-extra-file=*)
17:      defaults="$1"; shift
18:      ;;
19:esac
20:
21:parse_arguments() {
22:  # We only need to pass arguments through to the server if we don't
23:  # handle them here.  So, we collect unrecognized options (passed on
24:  # the command line) into the args variable.
25:  pick_args=
26:  if test "$1" = PICK-ARGS-FROM-ARGV
27:  then
28:    pick_args=1
29:    shift
30:  fi
31:
32:  for arg do
33:    case "$arg" in
34:      --force) force=1 ;;
35:      --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
36:      --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
37:      --user=*)
38:        # Note that the user will be passed to mysqld so that it runs
39:        # as 'user' (crucial e.g. if log-bin=/some_other_path/
40:        # where a chown of datadir won't help)
41:         user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
42:      --skip-name-resolve) ip_only=1 ;;
43:      --verbose) verbose=1 ;;
44:      --rpm) in_rpm=1 ;;
45:      --windows) windows=1 ;;
46:      *)
47:        if test -n "$pick_args"
48:        then
49:          # This sed command makes sure that any special chars are quoted,
50:          # so the arg gets passed exactly to the server.
51:          args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
52:        fi
53:        ;;
54:    esac
55:  done
56:}
57:
58:# Get first arguments from the my.cfg file, groups [mysqld] and
59:# [mysql_install_db], and then merge with the command line arguments
60:if test -x ./bin/my_print_defaults
61:then
62:  print_defaults="./bin/my_print_defaults"
63:elif test -x ./extra/my_print_defaults
64:then
65:  print_defaults="./extra/my_print_defaults"
66:elif test -x ./bin/my_print_defaults
67:then
68:  print_defaults="./bin/my_print_defaults"
69:elif test -x ./bin/mysql_print_defaults
70:then
71:  print_defaults="./bin/mysql_print_defaults"
72:else
73:  print_defaults="my_print_defaults"
74:fi
75:
76:args=
77:ldata=
78:execdir=
79:bindir=
80:basedir=
81:force=0
82:verbose=0
83:fill_help_tables=""
84:
85:parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
86:parse_arguments PICK-ARGS-FROM-ARGV "$@"
87:
88:test -z "$ldata" && ldata=./data
89:if test -z "$basedir"
90:then
91:  basedir=.
92:  bindir=./bin
93:  execdir=./bin
94:  pkgdatadir=./support-files
95:else
96:  bindir="$basedir/bin"
97:  if test -x "$basedir/libexec/mysqld"
98:  then
99:    execdir="$basedir/libexec"
100:  elif test -x "$basedir/sbin/mysqld"
101:  then
102:    execdir="$basedir/sbin"
103:  else
104:    execdir="$basedir/bin"
105:  fi
106:fi
107:
       .
       .
       .
我将77行的ldat该为了ldata=./data,还是提示

mkdir: 无法创建目录‘/var/lib/mysql/mysql’: 权限不够
chmod: 无法取得 ‘/var/lib/mysql/mysql’ 的属性: 没有那个文件或目录
mkdir: 无法创建目录‘/var/lib/mysql/test’: 权限不够
chmod: 无法取得 ‘/var/lib/mysql/test’ 的属性: 没有那个文件或目录

等错误,后来有查了写资料,好象/etc/my.cnf下有一些mysql的路径设置,我看了一下,就是上面的这些路径,
会不会是mysql_install_db中某个选项设置默认从/etc/my.cnf下找路径啊,如果是的话,如何修改啊,

再次感谢!!!

论坛徽章:
0
15 [报告]
发表于 2006-04-01 16:45 |只看该作者
哦,你的 mysql_install_db 原来和我的一样啊,我以为linux下的版本有什么不同的呢,呵呵
这样的话,这个脚本你不用做修改的,第88行就是这么做的。
你看看有没有 /etc/my.cnf 这个文件,如果是按照我的那种方法新装的话,不会存在这个文件,这个文件是安装的时候手工拷贝过去的。而且,你没有root权限,似乎也无法拷贝到 /etc/ 下。
如果有这个文件,而你有root权限的话,一,你可以修改里面的路径配置;二,干脆删除(不放心的话就改个名字),然后看 mysql/support-files/my-*.cnf,看开头的文字说明,决定你要把my.cnf放在哪里。
自己试一下吧,我只能提供参考。

论坛徽章:
0
16 [报告]
发表于 2006-04-01 17:39 |只看该作者
好的,我再试试,非常感谢您的帮忙!!!

不过如果搞不定的话还得向您请教!!!

论坛徽章:
0
17 [报告]
发表于 2006-04-02 11:23 |只看该作者
哎,还是 搞不定啊,把/etc/my.cnf删除后(我是在自己的机器上做实验的,所以自己有root的密码,所以可以把它删掉,但是我真正想装的那台机器 root密码在管理员手中)

后来又查看support-files下的my-medium.cnf

# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.

我把 my-medium.cnf拷贝到~/.my.cnf后,再运行./scripts/mysql_install_db

出现如下错误:

Installing all prepared tables
Fill help tables

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

我在网上搜  "To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system "这个错误

好像说是mysql.server没启动,于是运行 ./support-files/mysql.server

但是又出如下错误:


Starting MySQL...................................          [失败]

唉,还是搞不定啊,大哥再帮一下吧,感激不尽.......

论坛徽章:
0
18 [报告]
发表于 2006-04-02 15:42 |只看该作者
呵呵,还不行啊。
你写的:“出现如下错误:”一直到“我在网上搜 ”中间的那段,其实不是错误信息,是安装完mysql后,它给你的提示,告诉你如何启动,如何修改密码等信息。
我是习惯用 ./bin/mysqld_safe & 这个启动。
另外,它启动失败,你就去 mysql/data 下看错误日志,就是 err 后缀名的那个,看它里面写什么原因。
最后有一点,你说你要装的那台机器没有root权限,但是那台机器上有 /etc/my.cnf,那代表已经安装了 MySQL,那你再安装一份的话,要参考"如何安装多个 MySQL 服务"了,要用不同的端口等等。比较麻烦了。你还不如和管理员商量一下,说说你的要求了。

论坛徽章:
0
19 [报告]
发表于 2006-04-03 21:55 |只看该作者
再次感谢 rardge大哥 ,数据库服务终于启动了,也可以使用了,但是有一个小问题,关于密码设置的

我启动服务后,运行mysql -uroot -p然后回车,提示我输入密码,因为初始密码为空,我就直接回车了,然后
出现了mysql>
我输入show  databases;回车
显示出三个数据库表
information_schema
mysql
test
然后我输入create database wyp;回车
再运行show  databases;回车
显示出四个数据库表
information_schema
mysql
test
wyp
后来我输入use mysql;回车
选择了一个数据库,
然后输入update user set password="mysql" where user='root';回车(这句应该是给root设置密码的吧)
提示我修改成功,后来输入exit退出mysql;
之后再输入mysql -uroot -p回车
输入新设置的密码mysql
出错:ERROR 1045 (28000): Access denied for user 'root'@'localhost'

然后用空密码进 却可以进入数据库,但是只显示两个数据库表:
information_schema
test
另外两个不见了,也运行不了create database, 只能用显示出来的两个数据库,这是为什么,

还麻烦您给出个主意,或者说怎么能把密码删掉,恢复到原来密码为空状态.

谢谢!!!!

论坛徽章:
0
20 [报告]
发表于 2006-04-03 23:05 |只看该作者
你该好好看看置顶的 FAQ 帖子,忘记密码怎么办、如何修改用户密码,里面都有。
你的问题是:改密码的时候没有用 password() 函数;改好密码后没有 flush privileges 刷新。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP