1. 首先
下载
源码包:
ftp://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.1/mysql-5.1.72.tar.gz
2. 使用如下命令检查
系统中是否已安装mysql:
rpm -qa | grep mysql
3.没有安装则解压安装包然后进入该目录:
cd mysql
分别依次执行如下操作:
./configure --prefix=/usr/local/mysql --with-charset=gbk
make
make install
4.添加MySQL配置文件
如果你想要设置一个选项文件,使用support-files目录中的一个作为模板。在这个目录中有4个模板文件,是根据不同机器的内存定制的。
?
#cp support-files/my-medium.cnf /etc/my.cnf
?
5.设置开机自动启动
?
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#chmod 755 /etc/init.d/mysqld
#chkconfig –-add mysqld
#chkconfig –-level 345 mysqld on
?
6.创建mysql权限表:
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql
7.最后将安装目录的拥有者和所属组分别变更为root和mysql, 命令为:
chown -R root
chgrp -R mysql
8.测试成功否?
第一次运行会弹出如下信息,说明安装成功:
#/etc/rc.d/init.d/mysqld start
Initializing MySQL database:? Installing MySQL system tables...
OK
Filling help tables...
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/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
?
Alternatively you can run:
/usr/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 ; /usr/bin/mysqld_safe &
?
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
?
Please report any problems with the /usr/bin/mysqlbug script!
?
?????????????????????????????????????????????????????????? [? OK? ]
Starting mysqld:?????????????????????????????????????????? [? OK? ]
9.查看3306端口是否启动:
# netstat -altnp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 6946/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1892/rpcbind
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2726/dnsmasq
10.为了安全,需要修改密码,默认为空:
mysqladmin -u root password shallnet
至此,可以在命令行上面使用新的密码登录mysql了。