安装环境:
操作系统:suse Linux 10
数据库:MySQL 5.0.22
希望能认识更多高手,互相学习讨论技术!
首先发泄一下再这,网上看了N多安装mysql的文章,大多大同小异,都不能很好的安装mysql;多多少少都有问题;以个人之见大多为一份原文,拷贝到各自的博客或一些网上,纯属盗窃啊!上周末开始筹划安装suse以及mysql,一直到今天下午才终于到了show databases;太晕了!现在我将我安装mysql的每一步骤都放在这,以共需者查看,也以防日后自己再次观摩;
注意:在装suse linux时候一定选上C/C++开发那一项;听公司前辈说的。
具体安装步骤:
1.下载软件包mysql-5.0.22.tar.gz,地址http://www.mysql.com,一般不推荐安装rpm形式的;
2.把下载下来的mysql-5.0.22.tar.gz放在usr目录下并解压:
# tar zvxf mysql-5.0.22.tar.gz
4. ./configure --prefix=/usr/local/mysql --with-charset=gbk//设定安装目录,注意前面是./configure 点杠;
5.编译:# make //只是一个make就够了
6.安装:# make install //这两步都要一些时间
7.安装完添加一个mysql用户组并设置权限:
# useradd mysql # cd /usr/local/mysql# bin/mysql_install_db --user=msyql
# chown -R root:mysql .
# chown -R mysql var
# chgrp -R mysql .
# cp share/mysql/my-large.cnf /etc/my.cnf
8.设置开机自启动mysql服务:
# cp //usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql#chmod 755 /etc/init.d/mysql
#chkconfig --add mysql
# /etc/init.d/mysql start
然后重新启动系统:reboot 呵呵等吧
9.运行mysql
开机在终端进入mysql的目录:
启动服务:service mysql start
#cd /usr/local/mysql/bin# ./mysql -u root -p
输入你的密码即可进入mysql;
10.也可手动启动mysql服务:
# /usr/local/mysql/bin/mysqld_safe --user=root & //启动MySQL
# /usr/local/mysql/bin/mysqladmin -u root password “你的密码” //修改密码
12.关闭mysql服务:
# /usr/local/mysql/bin/mysqladmin -u root -pmysqlsecret shutdown //关闭MySQL
13.忘了卸载mysql的方法了补上:
进入mysql解压下的那个文件里
#cd /usr/mysql-5.0.22#make uninstall
mysql> grant all privileges on *.* to 'root'@'%' -> identified by 'root' with grant option; Query OK, 0 rows affected (0.05 sec)mysql> select host,user from mysql.user; +----------------+--------+ | host | user | +----------------+--------+ | 192.168.61.113 | root | | localhost | jason | | localhost | prod | | localhost | qsrock | | localhost | radius | | localhost | root | +----------------+--------+
# mysqladmin -uroot -p password 'newpassword' Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'
# /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: <输入新设的密码newpassword>
mysql>