本文共 1427 字,大约阅读时间需要 4 分钟。
一、下载的源代码版本是mysql-5.0.83
以下以root身份执行
二、添加用户和组
groupadd mysql
useradd -d /home/mysql -g [mysql组的id] mysql
或
useradd -d /home/mysql --user-group mysql
三、配置
具体的选项可看
./configure --help
./configure --prefix=/usr/local/mysql-5.0.83 --localstatedir=/usr/local/mysql-5.0.83/data --with-unix-socket-path=/usr/local/mysql-5.0.83/tmp/mysqld.sock --with-mysqld-user=mysql --enable-large-files --with-big-tables --with-charset=utf8 --with-extra-charsets=latin1,gb2312,gbk
四、编译和安装
make
make install
五、复制my.cnf配置文件
cd /usr/local/mysql-5.0.83
cp 编译目录/share/mysql/my-large.cnf ./my.cnf六、初始化数据库
cd 编译目录/script
./mysql_install_db --datadir=/usr/local/mysql-5.0.83/data
七、改变目录权限
chown -R mysql /usr/local/mysql-5.0.83
chgrp -R mysql /usr/local/mysql-5.0.83八、启动与停止mysql
启动:
/usr/local/mysql-5.0.83/bin/mysqld_safe --defaults-file=/usr/local/mysql-5.0.83/my.cnf --user=mysql
停止:
/usr/local/mysql-5.0.83/bin/mysqladmin -uroot -pcommunity-funnel -h<host> shutdown --sock=/usr/local/mysql-5.0.83/tmp/mysqld.sock
九、更改root密码并删除匿名账号
use mysql;
update User set Host='%' where User='root' and Host='127.0.0.1'delete anonymous accountgrant all privileges on *.* to identified by 'password'十、常见错误
mysqld_safe[25095]: started
STOPPING server from pid file /usr/local/mysql-5.0.83/data/localhost.localdomain.pidmysqld_safe[25111]: ended原因:
1.未执行./mysql_install_db --datadir=/usr/local/mysql-5.0.83/data可以查看data目录中是否有mysql test文件夹2.权限不对chown,chgrp改变目录权限
转载地址:http://cofmd.baihongyu.com/