Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1511
  • 博文数量: 1
  • 博客积分: 30
  • 博客等级: 民兵
  • 技术积分: 20
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-11 08:52
文章分类
文章存档

2012年(1)

我的朋友
最近访客

分类: 数据库开发技术

2012-04-11 08:53:23

1,
>mysql -uroot -p
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

>mysql -uroot -p --socket=/tmp/mysql.sock 可以启动,所以是sock问题

后来发现 my.cnf 有两个配置文件,/etc/mysql/my.cnf 多了一个这个,里面sock路径指定不一样所致,rename

>mv /etc/mysql/my.cnf /etc/mysql/my_cnf.bak

2,

Starting MySQL. * Manager of pid-file quit without updating file. 错误

wxianfeng@ubuntu:/usr/local/system/shell$ /etc/init.d/mysql start

Starting MySQL. * Manager of pid-file quit without updating file.

需要加sudo

3,查看mysql data目录

root@ubuntu:/usr/local/system/mysql/var# ps auxf | grep mysql

root     25756  0.0  0.0   4012   764 pts/3    S+   15:32   0:00  |           \_ grep --color=auto mysql

root     25000  0.0  0.0   4904  1400 ?        S    14:22   0:00 /bin/sh /usr/local/system/mysql/bin/mysqld_safe --datadir=/usr/local/system/mysql/var --pid-file=/usr/local/system/mysql/var/ubuntu.pid

mysql    25106  0.0  0.8 119652 16568 ?        Sl   14:22   0:00  \_ /usr/local/system/mysql/libexec/mysqld --basedir=/usr/local/system/mysql --datadir=/usr/local/system/mysql/var --user=mysql --log-error=/usr/local/system/mysql/var/ubuntu.err --pid-file=/usr/local/system/mysql/var/ubuntu.pid --socket=/tmp/mysql.sock --port=3306

可以看出在var ,注意 var目录的用户是 mysql ,必须root用户才能cd进入

sudo su # 切换到root用户

1,下载并且编译安装
download ()
archives 找到 ,注意下载的是source

sudo apt-get install g++ libncurses5-dev # 安装依赖的库

sudo  groupadd mysql  # 建立mysql用户组

sudo  useradd -g mysql mysql # 添加用户mysql

tar -zvxf mysql-5.1.51.tar.gz

cd mysql-5.1.51/

./configure --prefix=/usr/local/system/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=latin1(all) --with-plugins=innobase(all)  # config 很重要,括号里是或者

make

sudo make install

sudo cp support-files/my-medium.cnf /etc/my.cnf # 配置文件

注意mysql sock文件安默认装在tmp路径下 /tmp/mysql.sock,编译的时候 —with-plugins=all 建议加上 不然你会发现编译后不支持innodb引擎,那就麻烦了!

2, 初始化数据库并修改目录权限

cd /usr/local/system/mysql

sudo bin/mysql_install_db --user=mysql

sudo chown -R root .

sudo chown -R mysql /usr/local/system/mysql/var

sudo chgrp -R mysql .

3,启动mysql

bin/mysqld_safe --user=mysql &

netstat -antup | grep 3306

sudo cp /usr/local/system/mysql/share/mysql/mysql.server /etc/init.d/mysql

sudo killall mysqld # kill 刚刚启动的mysql

sudo /etc/init.d/mysql start|stop|restart|status # 重启mysql

4,添加PATH

>vim ~/.bashrc

export PATH="$PATH:/usr/local/system/mysql/bin"

wxianfeng@ubuntu:/usr/local/system/mysql/bin$ mysql --version

mysql  Ver 14.14 Distrib 5.1.51, for pc-linux-gnu (i686) using  EditLine wrapper

5, 修改mysql root 密码

>sudo /etc/init.d/mysql start --skip-grant-tables

>mysql -uroot -p mysql

>update user set password=passsword('root') where user='root';

重启mysql

ok root 账户的密码为root

6,怎么判断我的mysql是编译安装的

wxianfeng@ubuntu:~$ mysql --version

mysql  Ver 14.14 Distrib 5.1.51, for pc-linux-gnu (i686) using  EditLine wrapper

如果你是apt-get 安装的话就显示 for ubuntu-linux-gnu
yum
安装的话就显示 for redhat-linux-gnu

遇到的问题:

阅读(686) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~