日期:2014-05-16  浏览次数:20700 次

linux安装mysql(源码安装)

所有这些操作在Linux系统下进行,需要root权限

安装开始:

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql --with-charset=gb2312

shell> make

shell> make install

shell> cp support-files/my-medium.cnf /etc/my.cnf

shell> cd /usr/local/mysql

shell> bin/mysql_install_db --user=mysql

shell> chown -R root .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

(用mysql用户启动很重要。)

shell> bin/mysql -uroot -p

(输入密码,默认密码为空,直接回车即可)

shell> Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

如果出现上面的提示,说明mysql服务没有正常启动,因为mysql服务启动的话,会自动生成mysql.sock文件

shell> killall mysql

杀掉所有mysql进程,重新启动

shell> bin/mysql_install_db --user=mysql

重新启动

shell> bin/mysql -uroot -p