mysql linux安装 转载并修改为mysql 5.0.56
时间:2010-04-06 来源:xhq6632
一、编译mysql 5.0.56
#cd /usr/local/src
# tar zxvf mysql-5.0.56.tar.gz
# cd mysql-5.0.46
#./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
配置成功会提示:
MySQL has a Web site at http://www.mysql.com/ which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.
Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.
Thank you for choosing MySQL!
# make
编译的时间可能会比较长,毕竟优化的比较厉害。
# make install
编译安装完成后执行后续操作:
# useradd mysql //添加 mysql 用户
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . //设置权限,注意后面有一个 "."
# chown -R mysql /var/lib/mysql //设置 mysql 目录权限
# chgrp -R mysql . //注意后面有一个 "."
# cp share/mysql/my-large.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机自动启动 mysql。
# chmod 755 /etc/rc.d/init.d/mysqld
#前两步中的路径,系统不一样,导致路径有此变化
#我的是open suse 路径为/etc/init.d/mysqld
# chkconfig --add mysqld
# /etc/init.d/mysqld start //启动 MySQL
#/usr/local/mysql/bin/mysqladmin -u root password "password_for_root" // password_for_root为密码.本机是mysql
#/usr/local/mysql/bin/mysql –u root –p //进入mysql客户端
(/usr/local/mysql/bin/mysql -u root -p 提示Enter password: 输入密码,回车进入)
# /etc/init.d/mysqld start //关闭 MySQL
远程连接时如了出现:
INSERT INTO mysql.user (Host,User,Password) VALUES('%','plain',PASSWORD('123456'));
ERROR 1130: is not allowed to connect to this MySQL server
第一重要:查看Linux防火墙是否关掉;
再来看:
进入Linux
登录Mysql:
首先使用update把mysql.user中的root的host从localhost修改成%:
mysql> UPDATE mysql.user SET Host='%' WHERE Host='localhost' ;
mysql>GRANT ALL PRIVILEGES ON *.* TO root@"% ";
mysql> FLUSH PRIVILEGES ;
再次连接,显示成功。