shell> groupadd mysql
shell> useradd -g mysql mysql
shell> tar zxvf mysql-5.0.40.tar.gz
shell> cd mysql-5.0.40
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
修改my.cnf的内容
[mysqld]
datadir=/usr/local/mysql/demo -------编辑datadir的路径
basedir=/usr/local/mysql
port = 3306
socket = /tmp/mysql.sock
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql/demo ----安装初始数据库
shell> chown -R root mysql
shell> chown -R mysql :mysql demo
shell>cp ******/mysql.server /etc/init.d/mysql -----方便启动mysqld服务
shell> /etc/init.d/mysql start
-----mysq没密码可以这样解决
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables
--skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET
Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH
PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql
-uroot -p
Enter password: