今天MySQL在普通用户下无法启动,发现自己在Linux下安装MySQL出了问题,现在重新安装一遍mysql,
以下是具体步骤和说明,在这作个记录,省的以后重装的时候再找了。
shell> groupadd mysql(普通用户)
shell> useradd -g mysql mysql
为mysqld增加一个登录用户和组:
shell> gunzip
shell> cd mysql-VERSION
挑选一个你想解开分发包的目录,进入该目录
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
编译安装,自定义安装目录。
shell> cp support-files/my-medium.cnf /etc/my.cnf
如果想要配置为支持InnoDB表,应当编辑/etc/my.cnf文件,
去掉innodb_...开始选项行前面的#符,并将选项值改为你想要的。
注意的是:innodb格式的表支持事务
shell> cd /usr/local/mysql
进入安装目录。
shell> bin/mysql_install_db --user=mysql
如果用root运行命令,应当使用--user选项。
选项的值应与你在第一步为运行服务器所创建的登录账户相同。
如果用该用户登录来运行命令,可以省略--user选项。
用mysql_install_db创建MySQL授权表后,需要手动重新启动服务器
将程序二进制的所有权改为root,
数据目录的所有权改为你运行mysqld的用户。
如果位于安装目录(/usr/local/mysql)下,命令应为:
shell> chown -R root .
将文件的所有属性改为root用户。
shell> chown -R mysql var
将数据目录的所有属性改为mysql用户
shell> chgrp -R mysql .
将组属性改为mysql组。
shell> bin/mysqld_safe --user=mysql &
安装好以后测试启动服务器,
如果这个命令提示mysqld daemon ended并马上失败,
那么你能在数据目录中的文件“hostname'.err”找到一些信息。
如果从一个源码RPM开始,那么执行如下命令:
shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm
这样你制作一个可以安装的二进制RPM。
对于旧版本的RPM,你可能需要替换用rpm替换命令rpmbuild。注释:该过程不为任何MySQL账户设置密码。
然后以mysql这个普通用户登录,试验,即可。。。
edwin@Edwin:/usr/local/dev/mysql$ sudo ./bin/mysql_install_db --user=mysql
Installing MySQL system tables...
110103 19:16:56 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
110103 19:16:56 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
Filling help tables...
110103 19:16:57 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
110103 19:16:57 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
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:
/usr/local/dev/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/dev/mysql/bin/mysqladmin -u root -h Edwin password 'new-password'
Alternatively you can run:
/usr/local/dev/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/dev/mysql ; /usr/local/dev/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/dev/mysql/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 http://shop.mysql.com